私の質問はこのシナリオに属します
class A
{
public virtual void show()
{
Console.WriteLine("Hey! This is from A;");
}
}
class B:A
{
public sealed override void show()
{
Console.WriteLine("Hey! This is from B;");
}
}
class C:B
{
public new void show()
{
Console.WriteLine("Hey! This is from C;");
}
}
また
class A
{
public void show()
{
Console.WriteLine("Hey! This is from A;");
}
}
class B:A
{
public new void show()
{
Console.WriteLine("Hey! This is from B;");
}
}
上記のコードでは、クラス C はクラス B のメソッド Show() を非表示にします
Q. SuperClass で既に定義されているSubclass OverrideやHidesメソッドがないことをどのように確認できますか?
このようなもの、またはreadonly
フィールドに使用されるキーワードのようなものかもしれません
class A1
{
public sealed void show() // I know it will give compilation error
{
Console.WriteLine("Hey! This is from A1");
}
}
class B1 : A1
{
public void show()
{
Console.WriteLine("You must get a compilation Error if you create method with this name and parameter");
}
}
そんなキーワードある?
編集1:
はい、エクステンダーがメソッド名とパラメーターcozで正しい実装を使用していることを確認したいのですが、他の誰かがコードを調べた場合、それは正しいはずです