What are Virtual Methods?

The Virtual Modifier is used to mark that a method\property(ect) can be modified in a derived class by using the override modifier.

Example:

class A
{
    public virtual void Foo()
       //DoStuff For A
}

class B : A
{
    public override void Foo()
    //DoStuff For B

    //now call the base to do the stuff for A and B 
    //if required
    base.Foo()
}

Leave a Comment