is StringComparison.Ordinal the same as InvariantCulture for testing equality?

前端 未结 3 1353
暗喜
暗喜 2020-12-30 01:42

From their brief summary descriptions, it sounds like the string comparison rules StringComparison.Ordinal and StringComparison.InvariantCulture ar

3条回答
  •  礼貌的吻别
    2020-12-30 02:21

    It does matter, for example - there is a thing called character expansion

        var s1 = "Strasse";
        var s2 = "Straße";
    
        s1.Equals(s2, StringComparison.Ordinal);          // false
        s1.Equals(s2, StringComparison.InvariantCulture); // true
    

    With InvariantCulture the ß character gets expanded to ss.

提交回复
热议问题