Click here to Skip to main content
Full site     10M members (37K online)    

Simple Singleton Pattern in C#

The easiest singleton pattern is the one you used to the lock object itself.
 
Creating any variable as static readonly and initializing it directly (or via a static constructor) will already make it singleton.
Also, considering that "lock" clears all the caches, you don't need to declare the variable as volatile.
 
You must Sign In to use this message board.
Search 
Per page   
QuestionAbout that question on deserialization exception - it is caused by threading Pin
devvvy
30 Oct '12 - 16:30 
GeneralReason for my vote of 1 I'm a big fan of alternative 8, that... Pin
Kabwla.Phone
6 Nov '11 - 21:27 

Last Updated 9 Jul 2011 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2013