kiditerator.vb

来自「《ViSUAL BASIC》设计模式」· VB 代码 · 共 31 行

VB
31
字号
Imports System.Collections
Public Class KidIterator
    Implements IEnumerator
    
    Private index As Integer
    Private kidList As ArrayList
    '-----
    Public Sub New(ByVal col As Arraylist)
        index = 0
        kidList = col
    End Sub
    '-----
    Public Function MoveNext() As Boolean _
        Implements System.Collections.IEnumerator.MoveNext
        index = index + 1
        Return index < kidList.Count
    End Function
    '-----
    Public Sub Reset() Implements _
        System.Collections.IEnumerator.Reset
        index = 0
    End Sub
    '-----
    Public ReadOnly Property Current() As Object _
        Implements System.Collections.IEnumerator.Current
        Get
            Return kidList.Item(index)
        End Get
    End Property
End Class

⌨️ 快捷键说明

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