18 Sep 2017

What is Abstract class in C sharp


Abstract class is a keyword in an object oriented programming language and we never be create object in abstract class,


We can use abstract keyword before class and before method.

abstract method close with semicolon(;) ,

Syntax:-

 abstract class Program
    {

        public abstract void show();
        public void XYZ()
        {
            Console.WriteLine("I am Abstract class");
        }

    }

abstract method con not be use open close curly braces({--}),

abstract method use just like interface.

Example :-

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

namespace abstractclass
{
    abstract class Program
    {

        public abstract void show();
        public void XYZ()
        {
            Console.WriteLine("I am Abstract class");
        }
    }
    class ABC : Program
    {
        public override void show()
        {
            Console.WriteLine("Hello");
        }
        public void get()
        {
            Console.WriteLine("Hi");
        }
    }

}

1 comment:
Write comments

Popular Posts

Popular Posts

Translate

Total Pageviews