Articles → CSHARP → Difference The Singleton And Static Class In C#
Difference The Singleton And Static Class In C#
Difference
- A Singleton object can be passed as a parameter to a method because it is an instance of a class. In contrast, a static class cannot be passed as a parameter because it cannot be instantiated.
- A singleton class can implement interfaces, whereas a static class cannot.
- A Singleton class supports lazy loading, whereas a static class does not.
- A static class cannot be disposed because it cannot implement the IDisposable interface.
- A singleton instance is allocated on the managed heap, whereas a static class is not instantiated. Its static members are associated with the type itself rather than with an object instance.
| Posted By - | Karan Gupta |
| |
| Posted On - | Thursday, February 25, 2021 |