Consider the following code
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
public static Singleton Instance { get { return instance; } }
static Singleton() {}
private Singleton() {}
}
Question
1) Here what is the purpose of static constructor ? (I know static constructor will be called before the first instance of the class is created).But in the context of above code can't i use it without the static constructor?
2) I heard that one of the advantages of singleton is that it can be extended into factory. Since it is a sealed class ,how will you extend it into factory?can you give some example?