如何在此示例中加入LINQ select中的对象(也接受C#变体):
Class Room
Public Area As Integer
End Class
Class RoomPair
One As Room
Two As Room
End Class
Dim pairs as List(Of RoomPair) = mySource.GetRoomPairs()
' Select rooms with Area > 100 from my pairs '
Dim roomsAreaLargerThat100 = From p In pairs Select p.One, p.Two???
' roomsAreaLargerThat100 should be a IEnumerable or a List(Of Rooms) '
Run Code Online (Sandbox Code Playgroud)
展平列表,然后执行正常where条件:
pairs.SelectMany(p => new List<Room> {p.One, p.Two}).Where(r => r.Area > 100)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
115 次 |
| 最近记录: |