c# - Difference between ASCII comparison and string comparison -
I am using C #. When I am comparing two characters, by sending me the right output, like,
'-'. Compare ('!') // This is sending positive values to me 12 means '-' & gt; true But when I compare two strings of the same value, sending me different results <("!") // This is sending me negative value -1
means "-" & gt; False Can someone please explain to me why this is doing this? Should not it be true for both matters?
The comparison of the string is the culture culture that is why you get different results instead of String.CompareOrdinal , which byte is byte comparison. var v = '-' make comparisons ('!'); // 12 var s = String.CompareOrdinal ("-", "!"); // 12
Comments
Post a Comment