简体   繁体   English

String.Equals的奇怪行为?

[英]Strange behavior of String.Equals?

I have a dictionary that has keys as string. 我有一个字符串,键是字符串。

One item has peculiar behavior. 一个项目有特殊的行为。 For the same string, it is not matching. 对于相同的字符串,它不匹配。 I guess this has something to do with String.Equals behavior. 我想这与String.Equals行为有关。

Even String.Equals is returning wrong result. 甚至String.Equals返回错误的结果。 (I am aware of String intern concept, but this seems to be different issue). (我知道字符串实习生的概念,但这似乎是不同的问题)。

Check the image(watch window) for the issue. 检查问题的图像(观察窗口)。 在此输入图像描述

I am filling mappings dictionary (from xml resource file) as 我正在填充映射字典(来自xml资源文件)

var data = XDocument.Parse(str).Element(RootForXMLValidation).Elements().Where(x => x.Attribute("EcbFieldId") != null);
mappings = data.ToDictionary(x => x.Attribute("BoeField").Value.Trim(),
           x => new Mapping { Key = x.Attribute("BoeField").Value.Trim(),
           Type = (MappingType)Enum.Parse(typeof(MappingType), 
           x.Attribute("mappingType").Value), MappingDetail = x });

Why String.Equals behaving this way? 为什么String.Equals会以这种方式运行?

key的破折号似乎是一个短划线,而另一个是连字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM