ICollection(Of T) interface

mandelbrot

Centurion
Joined
Jul 1, 2005
Messages
194
Location
UK North East
Dear All,


I'm trying to implement the ICollection(Of T) interface. This would be fairly straight forward, but for some reason there are two implementations of the GetEnumerator function:
Visual Basic:
'Returns an enumerator to the address...
Public Function GetEnumerator() _
  As System.Collections.Generic.IEnumerator(Of IAddress) _
  Implements System.Collections.Generic.IEnumerable(Of IAddress).GetEnumerator
    ....
End Function

'Returns an enumerator to the IEnumerable interface...
Public Function GetEnumerator1() _
  As System.Collections.IEnumerator _
  Implements System.Collections.IEnumerable.GetEnumerator
    ....
End Function
I can understand that the second enumerator function is there due to the implementation of the IEnumerator in the ICollection interface, but what implications does it have on the operation of the class, and should I code it up independantly with an equivalent enumeration class?


Kind regards
Paul Weston
 
You could probably just do something like
Visual Basic:
Public Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
        Return GetEnumerator()
End Function
unless you really did require special handling of the non-generic version.
 
It's quite surprising that it's included, really, especially as I would have thoguht the 'Of T' should limit the class to a specific type...

Thanks for your help PD. ;)
 
Back
Top