Tuesday, 6 March 2018

How to call abstract class constructor. Prove it because can not create instance of abstract class so how it will called.

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

namespace AbstractClassInterfaceCalled
{
    abstract class Demo
    {
        static Demo()
        {
            Console.WriteLine("static constructor Demo");
        }
        public Demo()
        {
            Console.WriteLine("public constructor Demo");
        }

        public void Show()
        {
            Console.WriteLine("Abstract class Show method");
        }
    }
    class Program : Demo
    {
        static void Main(string[] args)
        {
            Program p = new Program();
            p.Show();
            Console.ReadLine();
        }
    }
}

output:-

static constructor Demo
public constructor Demo
Abstract class Show method

No comments:

Post a Comment