woensdag 31 augustus 2011

Singleton in C#

One of the most used design patterns is the singleton pattern. There are a lot of implementations in each language. Thanks to Jon Skeet, I could find the best implementations for C#.

I prefer this lazy and threadsafe implementation for all my pre .NET 4 applications:



The .NET 3's lambda expression and .NET 4's generic Lazy class can create a lazy and threadsafe implementation without subclass:

Geen opmerkingen:

Een reactie posten