Implementing the Singleton Pattern in C#
Implementing the Singleton Pattern in C#
For reference, I always use the fourth version:
For reference, I always use the fourth version:
public sealed class Singleton
{
static readonly Singleton instance=new Singleton();
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static Singleton()
{
}
Singleton()
{
}
public static Singleton Instance
{
get
{
return instance;
}
}
}
0 Comments:
Post a Comment
<< Home