代码
public abstract class BaseClass
{
public abstract void AbstractMethod();//abstract has not function body
public virtual void VirtualMethod()
{
Console.WriteLine(
"VirtualMethod From AbstractClass");
}
public void NonMethod()//nonAbstract nonVirtual
{
Console.WriteLine(
"NonMethod From AbstractClass");
}
}

public class SubClass : BaseClass
{
public override void AbstractMethod()
{
Console.WriteLine(
"Must Implement the abstract method in SubClass");
}
public override void VirtualMethod()
{
Console.WriteLine(
"Can override the virtual method if you want");
}
public new void NonMethod()
{
Console.WriteLine(
"Override NonMethod in subclass by NEW ");
}
}
class Program
{

static void Main(string[] args)
{
BaseClass s1
= new SubClass();
s1.AbstractMethod();
s1.VirtualMethod();
s1.NonMethod();


SubClass s2
= new SubClass();
s2.AbstractMethod();
s2.VirtualMethod();
s2.NonMethod();


}
}

 

Results:
Must Implement the abstract method in SubClass Can override the virtual method if you want NonMethod From AbstractClass Must Implement the abstract method in SubClass Can override the virtual method if you want Override NonMethod in subclass by NEW Press any key to continue . . .