Static is a Keyword and Singleton is a Design Pattern.
Static Classes can contain Static members only but Singleton can have Static as well as non static members also.
Singleton is the Object Creational pattern used for creating only single instance for a Class whereas Static itself is a Class and we can not create an instance for Static Class.
Singleton can implement Interfaces and it inherits from other Classes and it is follow the Object Oriented strategies.
We can passed Singleton Object as a Reference in a Method.
Singleton Supports the Object Disposal.
Singleton Object is stored on heap whereas Static Object is Stored in Stack.
We can clonned singleton Objects.
Below is the Tabular Representation of the Differences that specified above already.
Sr.No | Static | Singleton |
---|---|---|
1 | Static is a Keyword | Singleton is a Design Pattern |
2 | It Contains Static Members only | It can have Static and Non-Static Members |
3 | Can not create Instance of Static Class | Create only a single Instance of Singleton Class |
4 | Can have only Static Constructor | Can have only one Private Constructor |
5 | Can not implement an Interface | Can implement the Interface |
6 | Static is Stored in Stack Memory | Singleton Object is Stored in Heap Memory |
7 | Can not passed Static Class as a Reference Parameter in Method Call | We can passed Singleton Object as a Reference in a Method |
8 | Static Class not supports the Object Disposal | Singleton Supports the Object Disposal |
About the Author
Sudheer Singh Chouhan is a Software Engineer having Expertise in Development Design and Architecting the
applications , Project Management , Designing Large Scale Databases in SQL Server since last 17 Years.
Skill Sets :- Microsoft .NET technologies like ASP.Net Core, Web API, LINQ, Web Forms, WinForms, SQL Server,
EntityFramework, Design Patterns, Solid Principles, Microservices, AWS Cloud.