The Only C# .NET Singleton You’ll Ever Need
September 2, 2008
My colleague, Riaan Hanekom from NGenerics fame, showed me his perfect code for a singleton in C# .NET (version 2 and later). This generic class can create a singleton for any non-static class that has a default constructor.
/*
Copyright 2008 The NGenerics Team
(http://www.codeplex.com/NGenerics/Wiki/View.aspx?title=Team)This program is licensed under the Microsoft Permissive License (Ms-PL). You should
have received a copy of the license along with the source code. If not, an online copy
of the license can be found at http://www.codeplex.com/NGenerics/Project/License.aspx.
*/public static class Singleton<T> where T:new()
{
So simple, yet so complete…






January 13, 2009 at 2:05 am
Hi,
How are you using the google syntax highlighter on wordpress.com? I am sure you are not hosting your blog yourself.
Please let me know.
Thanks,
Manoj.
January 17, 2009 at 12:16 pm
http://support.wordpress.com/code/#posting-source-code