Well, the singleton-pattern has been around for quite a while, and I think it’s one the my most used (and for the longest time applied) patterns.
So far I implemented the singleton like this:
class Singleton { private static Singleton _instance; public static Instance { get { if (_instance == null) _instance = new Singleton(); return _instance; } } }
This did the trick so far, but recently I stumbled across a MSDN article that cleared a better and much shorter way to create a singleton:
sealed class Singleton { private Instance() {} public static readonly Instance = new Singleton(); }