Static vs Singleton

Though both restrict to have only one instance of the class to be created but there are differences:



It doesn’t maintain any state as no object is created. It maintains the state of object.
Static class gets activated at run-time. Singleton follows lazy loading, so object gets created when required.
It doesn’t implement interface. It implement interface.
Disposing Static is not possible, as types are only unloaded when the AppDomain shut down. They can be disposed at run time.
We can’t create object of Static class. Singleton object can be used as parameter.


Leave a comment

Filed under C#

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s