VB.net 泛型集合
作者:admin 日期:2009-11-10
程序代码Public Class MyGenericCollection(Of ItemType)
' 定义一个通用的集合
Private Items As Collection(Of ItemType)
' 建立构造函数
Public Sub New()
Items = New Collection(Of ItemType)
End Sub
' 返回集合中数据项的数量
Public ReadOnly Property Count() As Integer
Get
Return Items.Count
End Get
End Property
Public ReadOnly Property AllItems() As Collection(Of ItemType)
Get
Return Items
End Get
End Property
' 得到或设置一个特定的数据项
Public Property Item(ByVal Index As Integer) As ItemType
Get
Return Items(Index)
End Get
Set(ByVal value As ItemType)
Items(Index) = value
End Set
End Property
' 给集合添加新的数据项
Public Sub Add(ByVal Value As ItemType)
Items.Add(Value)
End Sub
' 从集合中删除数据项
Public Sub RemoveAt(ByVal Item As Int32)
Items.RemoveAt(Item)
End Sub
End Class
评论: 0 | 引用: 0 | 查看次数: 535
发表评论
上一篇
下一篇


文章来自:
Tags: 




