Generic Icollection Of <T>



我想创建<t>Icollection的对象
我的代码如下。

    Dim oAttributeValues As ICollection(Of AttributeValue)
        = TryCast(AttributeValuePropertyInfo.GetValue(UOMEn, Nothing),
                  ICollection(Of AttributeValue))

这里AttributeValue是我的类名。我想要这个类广义Bca我不知道创建了Collection的哪个类。

Public Class Collection(Of T As Class)
    Implements ICollection(Of T)
    Implements ICollection
    'Your code
End Class

请注意,您必须自己实现ICollection(Of T)ICollection接口。如果您不想要它,那么您可能想要从System.Collections.ObjectModel.Collection(Of T)继承。

Public Class Collection(Of T As Class)
    Inherits  System.Collections.ObjectModel.Collection(Of T)    
    'Your code
End Class

最新更新