"Mythran" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to create a custom collection for educational purposes only for now.
>
> I want to implement the IEnumerable interface but don't know what I'm doing
with
> it. How to I create/get/return the expected value for the implemented
> GetEnumerator() function? I know the value expected is an IEnumerator, but
what
> is it? Basically, I would like a nice, clean example to follow and learn from.
>
> Thanks 
>
> Haven't had much time to do any "real" searches for it on Google...trying here
> first as a quick-start...hopefully t'is all I need.
>
> Mythran
>
>
I think I figured it out....
Public Class MyCollectionEnumerator
Implements IEnumerator
#Region " Private Members "
' ==========================================================================
' Private Members
' ==========================================================================
Private mItems As MyItem() = Nothing
Private mIndex As Integer = -1
#End Region
#Region " Public Constructors / Destructors "
' ==========================================================================
' Public Constructors / Destructors
' ==========================================================================
Public Sub New(ByVal Items As MyItem())
mItems = Items
End Sub
#End Region
#Region " Public Properties "
' ==========================================================================
' Public Properties
' ==========================================================================
Public ReadOnly Property Current() As Object Implements
System.Collections.IEnumerator.Current
Get
Return mItems(mIndex)
End Get
End Property
#End Region
#Region " Public Methods "
' ==========================================================================
' Public Methods
' ==========================================================================
Public Function MoveNext() As Boolean Implements
System.Collections.IEnumerator.MoveNext
mIndex += 1
Return (mIndex > mItems.Length OrElse Not mItems(mIndex) Is Nothing)
End Function
Public Sub Reset() Implements System.Collections.IEnumerator.Reset
mIndex = -1
End Sub
#End Region
End Class
It works

ANything anyone sees as being wrong?
Mythran