2
所以我試圖創建一個通用表達式,可以用於我的所有類。類型T沒有定義
Function Test(field As String) As Func(Of T, String)
Dim xParam = Expression.Parameter(GetType(T), "o")
Dim prop = Expression.Property(xParam, GetType(T).GetProperty(field))
Dim lambda = Expression.Lambda(Of Func(Of T, String))(prop, xParam)
Return lambda.Compile()
End Function
但是T沒有定義。我如何在VB.NET中使用T?
'Function Test(Of T)(field As String)As Func(Of T,String)' – LarsTech