LINQ and CASE Sensitivity

后端 未结 4 1006
花落未央
花落未央 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 18:01

    OrderBy() returns results in ascending order.

    e comes before h, thus the first result (remember you're comparing on a substring that starts with the character in the 9th position...not the beginning of the string) and i comes before y, thus the second. Case sensitivity has nothing to do with it.

    If you want results in descending order, you should use OrderByDescending():

    TempRecordList.Cast
                  .OrderByDescending(s => s.Substring(9, 30)).ToArray());
    

提交回复
热议问题