The singleton pattern, due to being limited to a single thread-safe instance and its last minute instantiation, has a reputation for being cumbersome. Using Visual Studio, Jeremy McPeak demonstrates how to create a class limited to one instance, and seal the singleton for improved runtime performance. Jeremy then shows you how to expose the private instance class variable using a static property. Novice C# beginners will be able to implement the singleton pattern correctly and make their classes thread safe.

Grow your C# skills with the C# Learning Path on Safari.


Jeremy McPeak is a self-taught programmer who began his career tinkering with websites in 1998. He is the author of Beginning JavaScript, 5th Edition, JavaScript 24-Hour Trainer, and co-author of Professional Ajax, 2nd Edition. He also contributes to Tuts+ Code (http://code.tutsplus.com), providing articles, video tutorials, and courses on JavaScript, C#, ASP.NET, and PHP. He is currently employed by an oil and gas company, building in-house conventional and web applications.