I always implemented an IEnumerable object like this:
-----------------------
Class CollectionItem
.
.
.
End Class
Class Collection : Implements IEnumerable
Private InternalCollectionContent as Whatever(of CollectionItem)
.
.
.
Private Class CollectionEnumerator : Implements IEnumerator
Private InternalCollectionContent as Whatever(of CollectionItem)
.
.
.
End Class
End Class
------------------------
And it works just perfect !
But I noticed that on MSDN there is an exemple that is made to demonstrate how
to do the implementation. It goes like this:
-----------------------
Public Class CollectionItem
.
.
.
End Class
Public Class Collection : Implements IEnumerable
Private InternalCollectionContent as Whatever(of CollectionItem)
.
.
.
End Class
Public Class CollectionEnumerator : Implements IEnumerator
Public InternalCollectionContent as Whatever(of CollectionItem)
.
.
.
End Class
-----------------------
I do not understand why the Microsoft implementation method expose the IEnumerator class
as Public and I do not understand neither why the the internal content of the collection
is exposed (Public) from the IEnumerator class
What is the reason for this