---
title: "Static and Abstract Class"  
description: "/* Style Definitions */   table.MsoNormalTable  	{mso-style-name:\"Table Normal\";  	mso-tstyle-rowband-size:0;  	mso-tstyle-colband-size:0;  	mso-st"  
author: "Anonymous User"  
published: 2010-07-28  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/92/static-and-abstract-class  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Static and Abstract Class

##### Static Class

A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. That is, we cannot use the new keyword to create a variable of the class type. We can access the members of a static class by using the class name itself.

Abstract class

We cannot implement an instance of an abstract class; however we can implement methods, fields, and properties in the abstract class that can be used by the child class

## Example

![Static and Abstract Class](https://www.mindstick.com/mindstickarticle/9421a0bc-1a3f-4e54-9be8-255cc4528d38/images/a6994668-c6e2-44f5-8e66-43b365352e86.png)

```
   private void button1_Click(object sender, EventArgs e)        {            int a1, b1,s;    //creating instance of inherited class as object of abstract class            abs objAbs = new a();            a1 = 5;            b1 = 10;  //calling inc() method of static class            a1 = stat.inc(a1);  //calling sum()            s=objAbs.sum(a1, b1);           MessageBox.Show("Total no. of time inc called :" + stat.count.ToString());            MessageBox.Show("Sum: " + s.ToString());        }
```

\
Static Static class

\

```
    public static class stat    {      //creating static int variable        public static int count=0;      //creating static method        public static int inc(int x)        {            count++;            x += 10;            return x;        }    }
```

\

**Abstract class**

## \

```
    public abstract class abs    {        public abstract int sum(int x, int y);    } //class inheriting abstract class    public class a : abs    {//overriding abstract method of inherited abstract class        public override int sum(int x, int y)        {            y=stat.inc(y);            return (x + y);        }    }
```

**Screen shots**\

![Static and Abstract Class](https://www.mindstick.com/mindstickarticle/9421a0bc-1a3f-4e54-9be8-255cc4528d38/images/fd53e443-0cb8-46f6-a161-7957144573db.png) ![Static and Abstract Class](https://www.mindstick.com/mindstickarticle/9421a0bc-1a3f-4e54-9be8-255cc4528d38/images/1b4acfcd-bf67-4a1a-b8c0-a19162b1d2b4.png)

---

Original Source: https://www.mindstick.com/articles/92/static-and-abstract-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
