【发布时间】:2011-03-24 11:13:55
【问题描述】:
我有两个列表声明如下:
Dim lstDBItems As New List(Of DBItem)
Dim lstAppItems As New List(Of AppItem)
我正在尝试做这样的事情:
我有一个返回 List(Of AppItem) 的函数:
Function GetAppItems() As List(Of AppItem)
'...
End Function
在上面的函数中,我填充 lstDBItems,然后编写如下返回语句:
Return lstDBItems.Select(Function(x)
dim oItem As New AppItem()
oItem.Property1 = x.DbProperty1
'...
Return oItem
End Function)
奇怪的是代码可以编译,但在运行时我得到一个类型大小写错误。做我想要实现的目标的正确方法是什么......?
PS:请原谅截图被篡改。
【问题讨论】:
-
如果您有 Option Strict On 则不会编译
标签: .net vb.net extension-methods