Caselessly comparing strings in C#

前端 未结 6 1225
别那么骄傲
别那么骄傲 2020-12-17 16:21

Let\'s say I have two strings: a and b. To compare whether a and be have the same values when case is ignored, I\'ve always used:

// (Assume a and b have bee         


        
6条回答
  •  渐次进展
    2020-12-17 16:51

    ToLower() is not a comparison function, it puts the string to lower case. When the == operator is used on String objects in C# it is optimized by the compiler. At the core, Both depend on System.String.Equals as seen in Reflector.

提交回复
热议问题