Thursday, 31 January 2019

Using Singleton in C#

Singleton is used in application when we want to store consistent unique data in an object disallowing creating a new instances of this object in the same time.

Here are the bullet points that defines Singleton.

  • cannot be instantiated (private constructor instead of public)
  • cannot be inherited (sealed class)
  • public static instance has to be available across the whole application
Singleton concept is quite popular in mobile apps and video games, less in web/desktop applications.

Here is a simple example of Singleton usage.








No comments:

Post a Comment