mandelbrot Posted July 3, 2008 Posted July 3, 2008 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: '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 Quote
Administrators PlausiblyDamp Posted July 3, 2008 Administrators Posted July 3, 2008 You could probably just do something like 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mandelbrot Posted July 3, 2008 Author Posted July 3, 2008 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. ;) Quote
Administrators PlausiblyDamp Posted July 3, 2008 Administrators Posted July 3, 2008 The class could still be called from code that isn't expecting a generic version though. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.