我有一个要订购的号码列表。
List<int> numbers = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
如果我这样做,它工作正常
.OrderBy(n => n)
我试过,只是为了他妈的而已
.OrderBy(n => "ASC")
它没有用,但它没有抛出错误。如果我将鼠标悬停在 OrderBy 上,智能感知会显示,
IOrderedEnumerable<int> IEnumerable<int>.OrderBy<int,string>(Func<int,string> keySelector)
很好奇,这是为什么呢?
谢谢。
最佳答案
它不会抛出错误。您告诉它使用 "ASC"
进行比较,它就是这样做的。
关于c# - 为什么这个 OrderBy 没有抛出错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11812881/