Abstract properties in C#

In this article, we will find out about Abstract properties in C# with Example.

C# Abstract properties

A unique may contain some dynamic properties. That can be actualized in inferred class. Here we utilize unique and supersede catchphrases.

Example:

using System;
using System.Collections;

namespace ConsoleApplication1
{
    abstract class HUMAN
    {
        public abstract int ID
        {
            get;
            set;
        }

        public abstract string NAME
        {
            get;
            set;
        }

        public abstract int SALARY
        {
            get;
            set;
        }
    }

    class EMPLOYEE:HUMAN
    {
        private int     EMP_ID      ;
        private string  EMP_NAME    ;
        private int     EMP_SALARY  ;

        public override int ID
        {
            get
            {
                return EMP_ID;
            }

            set
            {
                EMP_ID = value;
            }
        }

        public override string NAME
        {
            get
            {
                return EMP_NAME;
            }

            set
            {
                EMP_NAME = value;
            }
        }

        public override int SALARY
        {
            get
            {
                return EMP_SALARY;
            }
            set
            {
                EMP_SALARY = value;
            }
        }

    }

    class Program
    {
        static void Main()
        {
            EMPLOYEE E = new EMPLOYEE();

            E.ID   = 101;
            E.NAME = "Duggu Pandit";
            E.SALARY = 1000000;

            Console.WriteLine("ID     : " + E.ID);
            Console.WriteLine("NAME   : " + E.NAME);
            Console.WriteLine("SALARY : " + E.SALARY);

        }
    }
}

Output

    ID		: 101
    NAME	: Durgesh Kaushik
    SALARY	: 10000000

Leave a Comment

error: Alert: Content is protected!!