我想做这样的事情:
Private _myCollection As IList(Of T)
Public Property MyProperty(Of T)() as IList(Of T)
Get
Return Me._myCollection
End Get
Set(ByVal value As String)
Me._myCollection = value
End Set
End Property
基本上,我想要拥有一个可以是任何类型的项目的集合。然后,我将能够做这样的事情:
Dim myPropertyValue as <the type of some value>
if (MyProperty.Contains(<some value>))
myPropertyValue = CType(MyProperty(<some value>), <the type of some value>)
我怎样才能做到这一点?或者有比使用泛型类型更好的方法吗?
您可能必须创建一个通用类才能执行此操作
Public Class MyClass(Of T)
Private _myCollection As IList(Of T)
Public Property MyProperty() as IList(Of T)
Get
Return Me._myCollection
End Get
Set(ByVal value As String)
Me._myCollection = value
End Set
End Property
End Class
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)