0
我有以下陣列LAMBDA不工作的陣列
Dim items() = {
New CheckedListBoxItem("NYC", False),
New CheckedListBoxItem("CHI", False),
New CheckedListBoxItem("PHL", False),
New CheckedListBoxItem("SFO", False),
}
我想對查詢像這樣
Try
Dim item As CheckedListBoxItem = items.ToList().Where(Function(x) x.Value = "PHL")
MsgBox(item.Value)
Catch ex As Exception
MsgBox(ex.Message)
End Try
我收到錯誤
值不能爲空值。
參數名:源
我也試過
Dim item As CheckedListBoxItem = items.FirstOrDefault(Function(x) x.Value.ToString() = "PHL")
我失去了什麼。我只需要根據列表查詢來獲取一個項目,並將它的checkedstate從false更改爲true。