Overriding Vs Shadowing
Overriding Vs Shadowing
Overriding changes implementation while shadowing replace the element with a completely new element only the interface vocabulary is same.
class A
{
public virtual void Function()
{
Console.WriteLine("A");
}
}
class B : A
{
public override void Function() // Overriding
{
Console.WriteLine("B");
}
}
class C : B
{
public new void Function() // Shadowing
{
Console.WriteLine("C");
}
}
Comments
Post a Comment