Singleton Vs Static Class

Wednesday, 27 May 2020

Singleton Vs 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#.

A class having all static methods.

Better performance (static methods are bonded on compile time)


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.

Methods can be overridden.

Can be lazy loaded when need (static classes are always loaded).

We can implement interface(static class can not implement interface).

No comments:

Post a Comment