方法名
说明
C# 查询表达式语法
Visual Basic 查询表达式语法
更多信息
OrderBy
按升序对值进行排序。
monospace; color: #006400; font-size: 14px;">orderby
Order By
Enumerable.OrderBy
Queryable.OrderBy
OrderByDescending
按降序对值进行排序。
orderby … descending
Order By … Descending
Enumerable.OrderByDescending
Queryable.OrderByDescending
ThenBy
按升序执行次要排序。
orderby …, …
Order By …, …
Enumerable.ThenBy
Queryable.ThenBy
ThenByDescending
按降序执行次要排序。
orderby …, … descending
Order By …, … Descending
Enumerable.ThenByDescending
Queryable.ThenByDescending
Reverse
颠倒集合中的元素的顺序。
不适用。
不适用。
Enumerable.Reverse<TSource>
Queryable.Reverse<TSource>
string[] words = { "the", "quick", "brown", "fox", "jumps" };
IEnumerable<string> query = from word in words orderby word.Length select word;
foreach (string str in query) Console.WriteLine(str);
string[] words = { "the", "quick", "brown", "fox", "jumps" };
IEnumerable<string> query = from word in words orderby word.Substring(0, 1) descending select word;
foreach (string str in query) Console.WriteLine(str);
string[] words = { "the", "quick", "brown", "fox", "jumps" };
IEnumerable<string> query = from word in words orderby word.Length, word.Substring(0, 1) select word;
foreach (string str in query) Console.WriteLine(str);
string[] words = { "the", "quick", "brown", "fox", "jumps" };
IEnumerable<string> query = from word in words orderby word.Length, word.Substring(0, 1) descending select word;
foreach (string str in query) Console.WriteLine(str);