简体   繁体   中英

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.

Even String.Equals is returning wrong result. (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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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