我遗漏了一些非常基本的东西,我不知道是什么……我对 Linq有一个例外: Dim arch As List(Of String)'gets archive as String() and casts it as Listarch = client.GetArchive().ToList() 'here exception occurs: Cannot cas
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正如它所述,你正试图将迭代器存储在列表中.
试试这个:
arch = arch.where(Function(x)x.EndsWith(System.Environment.UserName & ".htm")).ToList()
我更喜欢扩展linq,但它只是偏好,我的工作原因是因为ToList():)