我错过了一些非常基本的东西,我不知道是什么......我在遵循 Linq 时遇到异常:
Dim arch As List(Of String)
'gets archive as String() and casts it as List
arch = client.GetArchive().ToList()
'here exception occurs: Cannot cast object of type 'WhereSelectListIterator`2'...
arch = From a In arch
Where a.EndsWith(System.Environment.UserName & ".htm")
Select a
最佳答案
正如它所说,您正在尝试将 where 迭代器存储到列表中。
试试这个:
arch = arch.where(Function(x)x.EndsWith(System.Environment.UserName & ".htm")).ToList()
我更喜欢扩展 linq,但这只是偏好,我的扩展能够工作的原因是 ToList()
:)
关于vb.net - 无法运行基本 LINQ 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46905702/