C# Program Working of Constructor in Inheritance

using system;

public class BaseClass  // This is the main class
{
    public BaseClass()
    {
        // statement of 1st Base class constructor
    }

    public BaseClass(int Age)
    {
        // statement of 2nd Base class constructor
    }

    // Other classes comes here
}

public class DerivedClass : BaseClass  //  inheriting the class here.

{
    public DerivedClass()
    {
        // statement of 1st DerivedClass constructor
    }

    public DerivedClass(int Age):base(Age)
    {
        // statement of 2nd DerivedClass constructor
    }

    // Other classes comes here
}

No comments:

Post a Comment