Tuesday, August 9, 2016

Abstract vs Virtual

Abstract - no implementation (no body) ,
                 MUST overridden,
                 Child cannot call base.method(), because Abstract Method no body,
                 only for Abstract Class.
                 semicolon at end.

Virtual- MAY implementation,
              Can overridden, if you like to use child method , u can write it ,else it will use base method.
              Virtual Method Can call base.method(), straight call base class method

abstract class A
{
public virtual int testVrtual()
    {
       return 0;
    }
    
    public abstract int test();

}

No comments:

Post a Comment