Articles → CSHARP → Difference The Singleton And Static Class In C#

Difference The Singleton And Static Class In C#






Difference


  1. 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.
  2. A singleton class can implement interfaces, whereas a static class cannot.
  3. A Singleton class supports lazy loading, whereas a static class does not.
  4. A static class cannot be disposed because it cannot implement the IDisposable interface.
  5. 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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250