overriding

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

namespace overriding
{
    class Program
    {
        class Super
        {
            protected int x;
            public Super(int x)
            {
                this.x = x;
            }
            public virtual void display()
            {
                Console.WriteLine(x.ToString());
            }
        }
        class sub:Super
        {
            int y;
            public sub(int x,int y)
                : base(x)
            {
                this.y = y;
            }
            public override void display()
            {
                Console.WriteLine(y.ToString());
                base.display();
            }


        }
        static void Main(string[] args)
        {
            sub s = new sub(2, 3);
            s.display();
            Console.ReadLine();

        }
    }
}

Ebook Download
View all
Learn
View all