I am getting the following Compiler Warning:
'Resources.Foo.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. Resources.NET\Resources\Class1.cs 123 20 Resources
for this (very simplified) code:
public interface IFoo
{
int GetType();
string GetDisplayName();
}
public class Foo : IFoo
{
public int GetType() { return 3; } *** Warning: points to here (line 123)***
public string GetDisplayName() { return "Foo"; }
}
Note, what I don't get is why the GetDisplayName() function does NOT get a warning. I am clearly overlooking something.
I have poked around Stack Overflow and googled this error and it seems to apply to class inheritance, not interfaces. I am really confused why this would be triggered for the interface (which defines its methods as virtual).
Thanks in advance for the insight.
The GetType method is defined on the System.Object class, which is the ultimate base class of all classes of the Framework.
This method is used to get the Type of the current instance in runtime, and I think that you are not intending to override it (you have a int return type).
I suggest you to rename the method to GetFooType or something else, or implement your interface explicitly to avoid runtime problems.