Difference between Singleton Class and Static Class
In this blog you will learn difference between Singleton class and Static Class.
Static Class:
- You cannot create the instance of static class.
- Loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
- Static Class cannot have constructor.
- We cannot pass the static class to method.
- We cannot inherit Static class to another Static class in C#.
Singleton:
- You can create one instance of the object and reuse it.
- Singleton instance is created for the first time when the user requested.
- Singleton class can have constructor.
- You can create the object of singleton class and pass it to method.
- Singleton class does not say any restriction of Inheritance.
- We can dispose the objects of a singleton class but not of static class.