Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

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 Comment