IEnumerable.GetEnumerator() and IEnumerable<T>.GetEnumerator()
- by Dylan Lin
Hi,
In the .net framework, there's a generic IEnumerable<T> interface which inherits from the not-generic IEnumerable, and they both have a GetEnumerator() method. The only differents between these two GetEnumerator() is the return type.
Now I have a similar design, but when I compile the code, the compiler said:
MyInterface<T>.GetItem()' hides inherited member 'MyInterface.GetItem()'. Use the new keyword if hiding was intended.
The MyInterface<T>.GetItem() returns a concrete type T, while MyInterface.GetItem() returns type System.Object.
So I think if the BCL team guys compile the .net framework, they will get the same warning.
I think having compiler warnings is not good, what do you think? And how can I solve this problem? I mean I want to get the concrete type T when calling the MyInterface<T>.GetItem() not just a instance of type System.Object.
Thanks in advance! :-)