Tuesday, 21 February 2017

inheritance example program in c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication14
{
    public class baseclass
    {
        public baseclass()
        {
            Console.WriteLine("iam base class constructor");
        }
        public void print()
        {
            Console.WriteLine(" iam a parent class");
        }
    }
    public class deriverdclass : baseclass
    {
        public deriverdclass()
        {
            Console.WriteLine("iam derived class constructor");

        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            deriverdclass d = new deriverdclass();
            d.print();
        }
    }

}

output screenshot:







No comments:

Post a Comment