Static vs Singleton

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

Static

Singleton

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.

Ref

http://quickdotnetsolutions.blogspot.in/2011/05/difference-between-singleton-and-static.html

Leave a comment

Filed under C#

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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