从具有简单条件的数组中选择
Dim sites() As String = {"Stack Overflow", "Super User", "Ask Ubuntu", "Hardware Recommendations"}
Dim query = From x In sites Where x.StartsWith("S")
' result = "Stack Overflow", "Super User"
查询将是包含 Stack Overflow
和 Super User
的可枚举对象。查询中的 x
是迭代变量,其中将存储 Where
子句检查的每个对象。