Hi all,
Has anyone else noticed the differences in values returned by string comparison in C# and Java?
C#: Java*:
"1".CompareTo("2": -1 -1
"b".CompareTo("a": 1 1
"ant".CompareTo("art": -1 -4
"(".CompareTo("a": -1 -57
"!".CompareTo("_": -1 -62
"a".CompareTo("A": -1 32
"0".CompareTo("_": 1 -47
*of course, in .compareTo is used in Java, not .CompareTo.
Notice how for the last two, even the sign is different, implying a different concept of lexicographical ordering!
I know Java uses Unicode values. What does C# use?
Is there a way to get the same values out of C#?
Cheers,
Robin.
Has anyone else noticed the differences in values returned by string comparison in C# and Java?
C#: Java*:
"1".CompareTo("2": -1 -1
"b".CompareTo("a": 1 1
"ant".CompareTo("art": -1 -4
"(".CompareTo("a": -1 -57
"!".CompareTo("_": -1 -62
"a".CompareTo("A": -1 32
"0".CompareTo("_": 1 -47
*of course, in .compareTo is used in Java, not .CompareTo.
Notice how for the last two, even the sign is different, implying a different concept of lexicographical ordering!
I know Java uses Unicode values. What does C# use?
Is there a way to get the same values out of C#?
Cheers,
Robin.