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

前端 未结 3 1368
暗喜
暗喜 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:28

    For the extra credit question

    • Comparison confusion: INVARIANT vs. ORDINAL

      ... the notion of an Ordinal sort was added and an Ordinal member was added to the CompareOptions enumeration. Selecting it would ignore all of those cultural collation features and give you a binary sort that would also, incidentally, not vary.

    • string comparison InvariantCultureIgnoreCase vs OrdinalIgnoreCase?

    • C#: String comparison guidelines and common usage

      The recommendation states that for culture-agnostic comparisons use the Ordinal and OrdinalIgnoreCase comparisons. These are fast and also safe. They rely on byte matching and are excellent options for matching strings for internal (non-UI) processing.

提交回复
热议问题