关于IEnumerable接口,MSDN相关说明如下:
IEnumerator 接口
公共属性
Current 受 .NET Framework 精简版的支持。 | 获取集合中的当前元素。 |
公共方法
MoveNext 受 .NET Framework 精简版的支持。 | 将枚举数推进到集合的下一个元素。 |
Reset 受 .NET Framework 精简版的支持。 | 将枚举数设置为其初始位置,该位置位于集合中第一个元素之前。 |
一个实现该接口的例子:
Public Class ChildFormEnumerator
Implements IEnumerator
Private mintIndex As Integer
Private slEnum As SortedList
' The constructuor accepts one argument; the SortedList to enumerate.
Public Sub New(ByVal sl As SortedList)
slEnum = sl
mintIndex = -1
End Sub
' The Current property returns the form from the list
' using the index value.
Public ReadOnly Property Current() As Object Implements IEnumerator.Current
Get
Return slEnum.GetByIndex(mintIndex)
End Get
End Property
' MoveNext returns True if more items exist in the list
' to be enumerated, and False otherwise.
Public Function MoveNext() As Boolean Implements IEnumerator.MoveNext
If mintIndex >= slEnum.Count - 1 Then
Return False
Else
mintIndex += 1
Return True
End If
End Function
' Reset the enumerator so that the current position is one
' item before the first item in the list.
Public Sub Reset() Implements IEnumerator.Reset
mintIndex = -1
End Sub
End Class