---
title: "Abstract class in c#"  
description: "In this blog I am trying to explore the concept of Abstract class in c#:An Abstract class is an incomplete class (because of partial implementation)"  
author: "shreesh chandra shukla"  
published: 2013-07-15  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/548/abstract-class-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 4 minutes  

---

# Abstract class in c#

In this blog I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to explore the [concept of Abstract](https://www.mindstick.com/forum/158822/explain-the-concept-of-abstract-classes-and-their-significance-in-oop) [class in c#](https://www.mindstick.com/forum/160399/how-to-create-a-custom-generic-class-in-c-sharp-provide-an-example):

An [Abstract class](https://www.mindstick.com/articles/1430/abstract-class) is an incomplete class (because of partial implementation) or special class. Abstract class contains at least one [abstract method](https://www.mindstick.com/articles/23305/abstract-methods-and-class-in-c-sharp) and any number of defined method, we can't instantiate to abstract class because abstract method ([suppose if](https://answers.mindstick.com/qa/96854/what-you-do-suppose-if-dsl-pppoe-software-does-not-work-with-macintosh-computers) you able to create instance of abstract class ,then you may be call abstract method of abstract class which is invalid method call(method are not defined)) . We can use an Abstract class as a [Base Class](https://www.mindstick.com/blog/116/base-class-initilization). An Abstract method must be implemented in the non-Abstract class using the override keyword. After overriding the abstract method is in the non-Abstract class. We can derive this class in another class and again we can override the same abstract method with it.

##### Abstract classes have the following features:

- An abstract class cannot be instantiated.
- An abstract class may contain [abstract methods](https://www.mindstick.com/forum/159550/how-to-implement-an-interface-with-two-abstract-methods-by-a-lambda-expression) and accessors.
- It is not [possible to modify](https://answers.mindstick.com/qa/97470/is-it-possible-to-modify-the-data-once-it-is-written-in-a-block) an abstract class with the [sealed](http://msdn.microsoft.com/en-us/library/88c54tsw(v=vs.71).aspx) modifier, which means that the class cannot be inherited.
- A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.

##### Example

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;
namespace abstract_class{    class Program    {        static void Main(string[] args)        {            mathOperation mo = new mathOperation();            int res;            Console.Clear();            res = mo.add(5, 200);            Console.WriteLine(res);            res = mo.sub(50, 20);//base class method after override             Console.WriteLine("sum ={0}", res);            res = mo.divide(10,2);            Console.WriteLine("result of overloded function:{0}", res);            mo.message();            Console.ReadKey();
        }
    }
    class mathOperation : operation    {// base class abstract method implimented here        public override int add(int n1, int n2)        {            Console.WriteLine("the sum of number:{0}+{1}={2}", n1, n2, n1 + n2);
            int res = n1 + n2;            return (res);        }        //override base class method        public override void message()        {
            Console.WriteLine("good evening ");
        }
        public override int sub(int n1, int n2)        {            Console.WriteLine("the subtraction of number:{0}-{1}", n1, n2);            return (n1 - n2);
        }        public override int multi(int n1, int n2)        {            Console.WriteLine("the multiplication of number:{0}*{1}", n1, n2);
            return (n1 * n2);
        }        public override int divide(int n1, int n2)        {            Console.WriteLine("the divide of number:{0}/{1}", n1, n2);            return (n1 / n2);        }
    }     abstract class operation    {        public int number1, number2;        public operation(int n1 = 0, int n2 = 0)        {            this.number1 = n1;            this.number2 = n2;        }         public abstract int add(int n1, int n2);         public abstract int sub(int n1, int n2);         public abstract int multi(int n1, int n2);         public abstract int divide(int n1, int n2);         public virtual void message()        {
            Console.WriteLine("this is simple method of abstract class ");
        }
    }
}
```

---

Original Source: https://www.mindstick.com/blog/548/abstract-class-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
