I need to convert some string comparisons from vb to C #. The vb code uses> and <operators. I want to replace this with standard string string comparison methods. But, there the behavior I do not understand. To reproduce this, I have this test
[TestMethod]
public void TestMethod2()
{
string originalCulture = CultureInfo.CurrentCulture.Name;
var a = "d".CompareTo("t");
var b = "T".CompareTo("t");
Assert.IsTrue(a < 0, "Case 1");
Assert.IsTrue(b <= 0, "Case 2");
}
Can someone explain why b returns 1. My real understanding is that if it is case sensitive, then "T" must be preceded by "t" in sort order, i.e. -1. If it is case insensitive, it will be the same as 0
(FYI.Net Framework 4.5.2)
Many thanks
source
share