I'm need to convert some string comparisons from vb to c#. The vb code uses > and < operators. I am looking to replace this with standard framework string comparison methods. But, there's a behaviour I don't understand. To replicate this, I have this test
[TestMethod]
public void TestMethod2()
{
string originalCulture = CultureInfo.CurrentCulture.Name; // en-GB
var a = "d".CompareTo("t"); // returns -1
var b = "T".CompareTo("t"); // returns 1
Assert.IsTrue(a < 0, "Case 1");
Assert.IsTrue(b <= 0, "Case 2");
}
Could someone explain why b is returning 1. My current understanding is that if it is case sensitive then "T" should precede "t" in the sort order i.e. -1. If it is case insensitive it would be the same i.e. 0
(FYI .Net Framework 4.5.2)
Many thx