Search your topic here

Dynamic runtime polymorphism in C#

PRINCIPLES OF PROGRAMMING LANGUAGES
PRACT. Implement dynamic/runtime polymorphism in C#.

using System;

namespace ATC
{
    public class Parent
    {
        public virtual int Show()
        {
            return 1;
        }
    }

    public class Child : Parent
    {
        public override int Show()
        {
            return 2;
        }
    }

    class CSE
    {
        static void Main(string[] args)
        {
            Parent obj = new Child();
            Console.WriteLine("Show :" + obj.Show());
            Console.ReadKey();
        }
    }  
}

LEAVE A REPLY










Related topics

Please use contact page in this website if you find anything incorrect or you want to share more information about the topic discussed above.