次のコンパイラ警告が表示されます。
'Resources.Foo.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. Resources.NET\Resources\Class1.cs 123 20 Resources
この(非常に単純化された)コードの場合:
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"; }
}
私が得られないのは、なぜ GetDisplayName() 関数が警告を受けないのかということです。私は明らかに何かを見落としています。
Stack Overflow を調べてこのエラーをググったところ、インターフェイスではなく、クラスの継承に適用されるようです。なぜこれがインターフェイスに対してトリガーされるのか(メソッドを仮想として定義する)、私は本当に混乱しています。
洞察力を前もって感謝します。