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

Popular posts from this blog

iframe vs embed vs object in HTML 5

Constructor in c#

What is the need of method overriding ???