你的 Where 子句对我来说看起来很奇怪。您不应该使用 = 运算符,而不是 Is:
Dim q = From line In seats
Let data = line.Split(New [Char]() {" "c}, StringSplitOptions.RemoveEmptyEntries) ' it occurs in this line '
Let seatA = data(0)
Let seatB = data(1)
Let seatC = data(2)
Let seatD = data(3)
Let seatE = data(4)
Let seatF = data(5)
Where seatA = "." AndAlso seatB = "." '<------ Use = on this line not Is
Select seatA, seatF
你确定每一行都用空格而不是其他东西分隔吗?即使有 Is 也不应该导致 Null Ref。
这是我的示例程序,它似乎可以工作(在 LinqPad 中测试,它似乎不支持隐式行继续字符):
Sub Main
Dim seats As New List(Of String)()
seats.Add("1 2 3 4 5 6")
seats.Add(". . 9 8 7 6")
seats.Add(". . 5 5 5 5")
seats.Add("1 2 3 4 5 6")
seats.Add(". . 2 4 6 8")
seats.Add("1 2 3 4 5 6")
Dim q = From line In seats _
Let data = line.Split(New [Char]() {" "c}, StringSplitOptions.RemoveEmptyEntries) _
Let seatA = data(0) _
Let seatB = data(1) _
Let seatC = data(2) _
Let seatD = data(3) _
Let seatE = data(4) _
Let seatF = data(5) _
Where seatA = "." AndAlso seatB = "." _
Select seatA, seatF
q.Dump()
End Sub