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! :-)
Supplement: I'm saying the interfaces theirselves: IMyInterface inherits from IMyInterface, and they both have the GetItem() method (the IMyInterface.GetItem() returns type T, while IMyInterface.GetItem() returns type System.Object). The problem is that, if our code only have these two interfaces, that is, no derived concrete classes, we will encounter the compiler warning after compile the source code.