订购输出
Dim sites() As String = {"Stack Overflow",
"Super User",
"Ask Ubuntu",
"Hardware Recommendations"}
Dim query = From x In sites
Order By x.Length
' result = "Super User", "Ask Ubuntu", "Stack Overflow", "Hardware Recommendations"
OrderBy 子句通过子句返回的值对输出进行排序。在此示例中,它是每个字符串的长度。默认输出顺序为升序。如果需要降序,可以指定 Descending
关键字后子句。
Dim query = From x In sites
Order By x.Length Descending