http://computertriksno1.blogspot.in/

Inheritance - OOPS Programming

20 Oct 2017 0 comments

Inheritance: 

When a class acquire the property of another class is known as inheritance. Inheritance is process of object re-usability. For example, A Child acquire property of Parents.

public class ParentClass
    {
        public ParentClass()
        {
            Console.WriteLine("Parent Constructor.");
        }
        public void print()
        {
            Console.WriteLine("I'm a Parent Class.");
        }
    }
    public class ChildClass : ParentClass
    {
        public ChildClass()
        {
            Console.WriteLine("Child Constructor.");
        }
        public static void Main()
        {
            ChildClass child = new ChildClass();
            child.print();
        }
    }



Output:
    Parent Constructor.
    Child Constructor.
    I'm a Parent Class.
Share this article :

Post a Comment

 
Support : GDDon | Creating Website | Gddon |
Copyright © 2013. Computer Tricks and Tips for System - All Rights Reserved
Template Created by Creating Website Modify by GDDon.Com
Proudly powered by Blogger