LINQ and CASE Sensitivity

后端 未结 4 969
花落未央
花落未央 2021-01-22 16:57

I have this LINQ Query:

TempRecordList = new ArrayList(TempRecordList.Cast().OrderBy(s => s.Substring(9, 30)).ToArray());

It w

4条回答
  •  囚心锁ツ
    2021-01-22 17:53

    As already mentioned, the OrderBy() method takes a comparer as a second parameter.

    For strings, you don't necessarily have to implement an IComparer. You might be fine with System.StringComparer.CurrentCulture (or one of the others in System.StringComparer).

    In your exact case, however, there is no built-in comparer which will handle also the - after letter sort order.

提交回复
热议问题