IEnumerable and IEnumerator in the same class, bad idea?
Posted
by David Rutten
on Stack Overflow
See other posts from Stack Overflow
or by David Rutten
Published on 2010-03-25T20:36:38Z
Indexed on
2010/03/25
20:43 UTC
Read the original article
Hit count: 309
Is this a bad idea?
Private Class GH_DataStructureEnumerator(Of Q As Types.IGH_Goo)
Implements IEnumerable(Of Q)
Implements IEnumerator(Of Q)
....
....
'Current, MoveNext, Reset etc.'
....
....
Public Function GetEnumerator_Generic() As IEnumerator(Of Q) _
Implements IEnumerable(Of Q).GetEnumerator
Return Me
End Function
End Class
This class is only visible as an IEnumerable(Of T) readonly property, and it saves me an additional class that wraps IEnumerator(Of T). But somehow it just seems wrong. Is there a better way?
© Stack Overflow or respective owner