我想做这样的事情: 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 SetEnd Property 基本上,我想拥有
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