【发布时间】:2016-12-27 10:16:39
【问题描述】:
我想优化这段代码:
dim mPolNo as new Collection(Of String)
For Each _olap As clsOLAP in cscOLAPs
mPolNo.Add(_olap._p1.PolNo)
Next
(PolNo的数据类型为String)
我尝试使用我在 google 中挖掘的 Collection.Select。
mPolNo = cscOLAPs.Select(Function(x) x._p1.PolNo.ToString)
但我遇到错误提示:
Unable to cast object of type 'WhereSelectEnumerableIterator`2[SIPLib.ING.clsOLAP,System.String]' to type 'System.Collections.ObjectModel.Collection`1[System.String]'.
【问题讨论】:
标签: string vb.net linq collections lambda