Static vs Singleton in C# (Difference between Singleton and Static)

Posted by Jalpesh P. Vadgama on ASP.net Weblogs See other posts from ASP.net Weblogs or by Jalpesh P. Vadgama
Published on Tue, 25 Jun 2013 12:43:00 GMT Indexed on 2013/06/25 16:22 UTC
Read the original article Hit count: 610

Filed under:
|
Recently I have came across a question what is the difference between Static and Singleton classes. So I thought it will be a good idea to share blog post about it.

Difference between Static and Singleton classes:

  1. A singleton classes allowed to create a only single instance or particular class. That instance can be treated as normal object. You can pass that object to a method as parameter or you can call the class method with that Singleton object. While static class can have only static methods and you can not pass static class as parameter.
  2. We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.
  3. We can clone the object of Singleton classes we can not clone the object of static classes.
  4. Singleton objects stored on heap while static class stored in stack.

more at my personal blog: dotnetjalps.com

© ASP.net Weblogs or respective owner

Related posts about ASP.NET

Related posts about c#.net