c# - 为什么这个 OrderBy 没有抛出错误?

标签 c# asp.net

我有一个要订购的号码列表。

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/

相关文章:

c# - 如何确定控件是否开始初始化并完成初始化和绑定(bind)

c# - 如果 Task.Wait 尚未运行,它是否会启动任务?

c# - JavaScript 调用页面方法 : error 500. JSON

asp.net - ASP.NET MVC 4 的 Windows 身份验证 - 它如何工作,如何测试它

c# - 从进程中获取当前打开的 Word 文档

c# - 多个main方法有什么用?

c# - Entity Framework Fluent API 映射

asp.net - 哪个控件发回了我的页面? (ASP.NET 页面)

asp.net - 在 Visual Studio Ultimate 中找不到打开的网站

asp.net - C# ASP.NET 通过 TLS 发送电子邮件