I was going through the following Singleton implementation mentioned here. I understand static constructors get executed before the first static method call or before te object is instantiated, but did not understand its use here (even from the comments). Could anyone help me understand it?
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static Singleton()
{
}
private Singleton()
{
}
public static Singleton Instance
{
get
{
return instance;
}
}
}