---
title: "Difference between Singleton class and Static class"  
description: "Static class in like the normal class the feature of static class is that we can make object of static class and it contain only static members. This"  
author: "Manish Kumar"  
published: 2017-03-02  
updated: 2018-03-17  
canonical: https://www.mindstick.com/blog/11312/difference-between-singleton-class-and-static-class  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Difference between Singleton class and Static class

**[Static](https://www.mindstick.com/articles/12098/the-static-keyword-the-static-methods) class**\

Static class in like the normal class the [feature](https://www.mindstick.com/forum/541/what-is-new-feature-in-sql-server-2012) of static class is that we can make object of static class and it contain only static members. This is also knowns as [sealed class](https://www.mindstick.com/forum/33880/difference-between-abstract-class-and-sealed-class) means we cannot inherit it into the [child class](https://www.mindstick.com/forum/159389/how-to-remove-child-class-from-active-div).

Static class can have only [one constructor](https://www.mindstick.com/forum/159570/how-to-call-one-constructor-from-another) without [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp), we cannot create parameterize constructor because to [pass value](https://www.mindstick.com/forum/378/how-to-pass-value-from-one-controller-to-another-controller) of constructor we need to create object and we cannot create object of static class.

**[Advantages](https://www.mindstick.com/articles/12841/5-advantages-of-customer-portal-you-didn-t-know-about)-**

It provides [guarantee](https://www.mindstick.com/blog/12905/microsoft-mcp-ai-100-test-preparation-material-pass-with-guarantee) that object cannot be created.

It can have only one constructor without any parameter.

**Let us understand with an example-**

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;                                 namespace
ConsoleApplication10{        public static class MyMath    {        public static float PI = 3.14f;        public static int cube(int n) { return n * n * n; }    }    public class A    {        public void function()        {            Console.WriteLine("class A");        }    }    class TestMyMath    {        public static void Main(string[] args)        {            Console.WriteLine("Value of PI is: "+ MyMath.PI);            Console.WriteLine("Cube of 3 is:"+ MyMath.cube(3));            //MyMath obj = new MyMath();//error            A obj = new A();            obj.function();                     }    }     }
```

![Difference between Singleton class and Static class](https://www.mindstick.com/blogs/00871f60-85fe-46ae-97b0-adf4b0f941ee/images/59a1aee7-0924-416c-9697-70699d9ce556.png)\

\

\

**Singleton**

This pattern involves a single class which is responsible to create an object

\

while making sure that only single object gets created. It just says that you

\

define only one instance and provide global access to it.

\

\

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ComponentModel;namespace SingleTonSample{    sealed class SingleTon    {        private static SingleTon single = new SingleTon();        public static SingleTon Instance         {            get { return single; }         }        private SingleTon(){ }        public void PrintMe()        {            Console.WriteLine("Singleton Class Testing");        }    }}
```

\

You can visit these helpful related post.

\

[What is a singleton in C#?](https://www.mindstick.com/Interview/2169/what-is-a-singleton-in-c-sharp)

---

Original Source: https://www.mindstick.com/blog/11312/difference-between-singleton-class-and-static-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
