【发布时间】:2011-08-01 15:08:22
【问题描述】:
我在 vb.net 中有这个函数,我从 C# 转换为我正在处理的项目。
Private Function GetAllFactory(Of T)(ByVal ctor As Construct(Of T)) As List(Of T)
'TODO: Data Access stuff
Dim ds As New DataSet()
Dim entities = New List(Of T)()
For Each dataRow As DataRow In ds.Tables(0).Rows
Dim entity As T = ctor(dataRow)
entities.Add(entity)
Next
Return entities
End Function
和下面的委托
Private Delegate Function Construct(Of T)(ByVal dataRow As DataRow) As T
我尝试将代码转换为从 C# 调用函数到 vb.net
Return GetAllFactory(Of MyType)(row >= New MyType(row))
上面的行不起作用。我有点卡住了。我在 C# 中使用 lambda 的次数不多,在 vb.net 中使用得更少。
MyType 构造函数:
Public Sub New(ByVal dataRow As DataRow)
.
.
.
End Sub
关于如何调用 GetAllFactory 有什么建议吗?
【问题讨论】: