|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How'd they do that?I'm trying to implement a custom collection, but I'm having trouble trying to
duplicate some of the "features" found in the generic collections. Specifically, implementing both the IEnumrable interface as well as the IEnumerable<T> interface. When I click on "Goto Definition" of List<T> it shows that List<T> implements both interfaces, but HOW? IEnumerable<T> specifies a method like: T GetEnumerator(); IEnumerable specifies a method like: Object GetEnumerator(); You can't implement both because the signatures only differ by return type. What trick am I missing? microsoft.private.whidbey.csharp.ide || .language is the newsgroup you would
want to post to Show quote "dkocur" <dko***@discussions.microsoft.com> wrote in message news:2A401EED-703B-4AE8-A20C-DEDDEB019B3B@microsoft.com... > I'm trying to implement a custom collection, but I'm having trouble trying to > duplicate some of the "features" found in the generic collections. > Specifically, implementing both the IEnumrable interface as well as the > IEnumerable<T> interface. When I click on "Goto Definition" of List<T> it > shows that List<T> implements both interfaces, but HOW? > > IEnumerable<T> specifies a method like: > > T GetEnumerator(); > > IEnumerable specifies a method like: > > Object GetEnumerator(); > > You can't implement both because the signatures only differ by return type. > What trick am I missing? >You can't implement both because the signatures only differ by return type. Explicit implementation:>What trick am I missing? public IEnumerator<T> GetEnumerator() { ... } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator() } Mattias -- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. |
|||||||||||||||||||||||