Thursday, 6 September 2012

Inheritance using C#

Inheritance is mechanism by which a class can inherit the property of the Base class. A derived class can access all Non-private member of the base class.
Classes can inherit from another classThis is accomplished by putting a colon after the class name when declaring the class

public class A
{
    public A() { }
}

public class B : A
{
    public B() { }
}


Then gains all the non-private data and behavior of the base class in addition to any other data or behaviors it defines for itself.

No comments:

Post a Comment