<分区>
我的问题属于这种情况
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. How i can be sure that no Subclass Override as well as Hides method which are already defined in SuperClass
类似这样的东西或者可能像 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:
Yes i want to prevent the extender to be sure that it uses the right implementation with the method name and parameter coz if some one else looks into code it should be right