2 u010753474 u010753474 于 2014.11.01 03:22 提问

泛型函数如何定义泛型委托
Class cA
Function F(Of T)(ByVal Num As T) As T

End Function
Delegate Function _F(Of In T, Out O)(ByVal Num As T) As O

Shadows F As _F(Of T, O) = New _F(Of T,O)(addressof F(Of T)

End Class

Shadows F As _F(Of T, O) = New _F(Of T,O)(addressof F(Of T)

上面这一句报错,具体该如何声明呀,主要意图是保留泛型元素。如果有N个副本就要每一个分别声明委托吗?例如:

 Function F(Of T)(ByVal Num As Integer) As T

End Function
Function F(Of T)(ByVal Num As Long) As T

End Function
Function F(Of T)(ByVal Num As Short) As T

End Function

不会是三个副本要声明三个委托吧。FByte,FInteger,FShort?

Csdn user default icon
上传中...
上传图片
插入图片