HashSet或==签名(HashSet or == sign)
我在vars
doc1
有两个50kb的字符串数据,doc1
通过实体框架从数据库中获取。 我想比较这两个变量,看看doc1和doc2是否相等。 我可以获取字符串的hashset并比较哈希值。 或者我可以简单地使用if (doc1 == doc2)
是否有更好的第三种选择?如果没有第三个选项,那么就优化,性能以及IL在后台做什么而言,是否有人对hashset v。
==
有任何建议(逻辑上是好的)? 我想,hashset
必须以线性方式扫描字符串到最后才能创建一个唯一的哈希字符串(两个变量)。==
。 那么哪一个在逻辑上更好?I have two 50kb string data in vars
doc1
anddoc2
coming form the database through entity framework. I want to compare these two vars to see if doc1 and doc2 are equal. I can take the hashset of the strings and compare the hashes. Or I can simply useif (doc1 == doc2)
Is there a third option that's better?If there is no third option, does anyone have any suggestion (a logical one is good) in regards to hashset v.
==
in terms of optimization, performance and what IL does in the background? I would imagine that ahashset
would have to scan the string in a linear fashion to the end to create a unique hash string (for two vars). So does==
. Then which one is logically better?
原文:https://stackoverflow.com/questions/25802257
最满意答案
您可以在Reference.cs文件中重命名生成的
System
类(及其对它的所有引用),然后向其添加[XmlRoot(ElementName = "System")]
属性,以便正确(de)序列化。重新生成代理时,您当然会丢失这些更改。
You can rename the generated
System
class (and all references to it) in the Reference.cs file, then add a[XmlRoot(ElementName = "System")]
attribute to it so it will be (de)serialized properly.You'll of course lose these changes when you regenerate the proxy.
相关问答
更多-
无法使用“添加服务引用”为自托管服务生成代理(Unable to generate a proxy for a self-hosted service with “Add Service Reference”)[2023-05-30]
在ServiceHost中启用元数据交换行为。 using(ServiceHost host = new ServiceHost(typeof(MiniCalcService.Service), new Uri("http://localhost:8091/MiniCalcService"))) { host.AddServiceEndpoint(typeof(MiniCalcService.IService), ... -
添加服务引用后,在服务引用下打开文件Reference.svcmap (您可能需要在“项目”菜单中启用“显示所有文件”选项)。 找到
元素,并将其值更改为false。 这将从生成的数据合约中移除INotifyPropertyChanged 。 After you add the service reference, open the file Reference.svcmap under the service reference (you may need to ena ... -
我有同样的问题,并解决它如下 1。 从您的服务参考中删除DynamicsCom 2。 清理解决方案 3。 重新添加服务参考并给出相同的名称“DynamicsCom” 4。 右键单击DynamicsCom,然后转到配置服务参考 5。 重新构建解决方案,它现在应该可以正常工作 谢谢 I had the same issue, and resolved it as follows 1 . Remove DynamicsCom from your service refernces 2 . Clean the so ...
-
我今天自己遇到了这个。 解决方案是使用FaultContract中不从Exception继承的对象。 如果您查看关于FaultException和FaultContract的MSDN文档,您将看到官方示例使用普通类(具有DataContact属性),而不是为FaultException.Detail扩展Exception的类。 我不确定为什么Exception导致添加服务引用失败,但我怀疑它与序列化或检索自定义异常的类型信息有关。 我已经在示例实现之前和之后包括了工作方法。 之前(没有工作): [Servi ...
-
服务参考错误:无法生成服务引用的代码(Service Reference Error: Failed to generate code for the service reference)[2023-07-23]
必须从配置服务引用选项中取消选中所有引用程序集中的重用类型 检查这个细节 Have to uncheck the Reuse types in all referenced assemblies from Configure service reference option Check this for details -
双工服务引用将接口类型转换为system.object类型(Duplex service reference converts interface type to system.object type)[2023-05-08]
好吧,我搜索过高低。 最后,我已经恢复使用可序列化的具体类,而不是尝试在我的服务引用中使用接口。 Well, I have searched high and low. In the end I have reverted back to using serializable concrete classes instead of trying to use interfaces in my service reference. -
DataContractSerializer不支持System.IO.DirectoryInfo类。 相反,您可以尝试使用XmlSerializer,但您可能会遇到其他问题。 一个简单的解决方案是添加一个string属性,该属性捕获重新创建正确对象所需的数据。 您也可以保留原始属性,只需确保使用[NonSerialized]属性进行标记即可。 或者,您可以使用OnSerializing和OnDeserializing属性来确保DirectoryInfo值存储在字符串字段中,以便在反序列化后还原Directo ...
-
配置服务引用对话框使您可以配置生成的代理的行为。 这包括配置用于集合和词典的类型的选项。 如果IDictionary不在那里,您可能无法生成从Visual Studio中使用它的代理。 但请记住,生成的客户端只需以商定的格式交换数据。 如果您可以使用包含服务合约(或服务合同格式正确)的程序集,则可以使用渠道工厂生成客户端。 通过网络发送的数据格式将相同,因此与您的服务兼容。 你可以在这里看到一个渠道工厂的简单例子。 The Configure Service Reference dialog box ena ...
-
为什么ASP.NET试图为Web服务引用生成临时类?(Why is ASP.NET trying to generate a temporary class for a Web Service reference?)[2021-08-20]
您有一个生成的类,允许您调用Web服务。 ASP.NET会自动生成一个临时类来将XML序列化/反序列化。 You have a generated class that allows you to call the web service. ASP.NET is auto-generating a temporary class to serialize/deserialize the XML into. -
.Net使用服务生成服务引用类型为“System”(.Net Generate Service Reference with Service Having type “System”)[2022-07-01]
您可以在Reference.cs文件中重命名生成的System类(及其对它的所有引用),然后向其添加[XmlRoot(ElementName = "System")]属性,以便正确(de)序列化。 重新生成代理时,您当然会丢失这些更改。 You can rename the generated System class (and all references to it) in the Reference.cs file, then add a [XmlRoot(ElementName = "System" ...