- As singteton can implement interface, inheritance from other classes and allow inheritance.
- While a static class cannot inherit their instance members.
- static is a keyword but singteton is a design pattern.
- In singleton, we have control over the object creation of the class But, we have no control on the static class object creation.
- Static class objects cannot be passed as parameters to other methods. But we can pass instance of a singleton as parameter to another method.
- We can clone the singleton class object whereas it is not possible to clone a static class.
- It is possible to dispose the objects of a singleton class whereas it not possible to dispose of a static class.
- Singleton objects stored in heap while static class stored in stack.
- When the compiler compiles the static class then internally it treats the static class as an abstract and sealed class.
This is the reason why neither we create an instance nor extend a static class in C#
Tags:
OOPS/C#