Tuesday 2 February 2016

Difference between Singleton and Static class?



Singleton:-
1)      Singleton is a design pattern which is a solution for recurring to the problems.
2)      Singleton is used to create the object of class only once.
3)      Singleton may contain non-static member as well.
4)      Singleton class has a constructor.
5)      Does not have the restriction for inheritance.
6)      Can dispose object of singleton class.

Static Class:-
1)      Cannot create instance of static class.
2)      Does not contain non-static member.
3)      Does not have constructor.
4)      Cannot inherit static class to another static class.
5)      Load automatically by .net framework CLR.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.