personlist.vb

来自「對c#初學者參考..為課題asp.net 2.0教材代碼」· VB 代码 · 共 38 行

VB
38
字号
Imports Microsoft.VisualBasic

Imports System.Collections
Public Class PersonList
    Implements System.Collections.IEnumerable

    Private innerList As ArrayList = New ArrayList()

    Public Sub Add(ByVal aPerson As Person)
        innerList.Add(aPerson)
    End Sub

    Public Sub Remove(ByVal aPerson As Person)
        innerList.Remove(aPerson)
    End Sub

    Public ReadOnly Property Count() As Integer
        Get
            Return innerList.Count
        End Get
    End Property

    'Get/set element at given index
    Default Public Property Item(ByVal index As Integer) As Person
        Get
            Return CType(innerList(index), Person)
        End Get
        Set(ByVal Value As Person)
            innerList(index) = Value
        End Set
    End Property

    Public Function GetEnumerator() As IEnumerator _
            Implements IEnumerable.GetEnumerator
        Return innerList.GetEnumerator()
    End Function
End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?