s

C# Abstract Class edit button Edit

author
Rakesh Kumar Sutar | calendar 20 January 2021 | 3221

Introduction

Abstraction in C# is the process to hide the internal details and showing only the functionality. The abstract modifier indicates the incomplete implementation. The keyword abstract is used before the class or method to declare the class or method as abstract.

Example

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

namespace Hello_World
{

    class Programs
    {
        public abstract class Addition
        {

            
            public abstract void add();

        }

        
        public class first_1 : Addition
        {

           
            public override void add()
            {
                Console.WriteLine("\t" 10 20);
            }
        }

        
        public class Second_2 : Addition
        {

           
            public override void add()
            {
                Console.WriteLine("\t" 50 50);
                Console.ReadLine();
            }
        }

        static void Main(String[] args)
        {
            
            Addition g;

           
            g = new first_1();

            
            g.add();

           
            g = new Second_2();

            
            g.add();

        }
    }

    

}

Output