The question: there is two classes, A and B
public abstract class A
{
public A()
{
Console.WriteLine("A");
}
public virtual void Fun()
{
Console.WriteLine("A.Fun()");
}
}
public class B : A
{
public B()
{
Console.WriteLine("B");
}
public new void Fun()
{
Console.WriteLine("B.Fun()");
}
}
If run:
public void Main()
{
A a = new B();
a.Fun();
}
the output is:
A
B
A.Fun()
How to explain this result, I know it has something to do with abstract and suclassing, but I don't know how to explain. Please help.