What are possible different ways using various language constructs to implement a Singleton pattern in C# and in which situation each solution is used? What are the advantages and disadvantages of each implementation? and, which is the best one of those implementations considering performance, locking and garbage collection implications?
What other ways are present to implement the same and how can the below code be improved:
public class Singleton
{
private static readonly Singleton _instance;
private Singleon()
{
}
public static Singleton GetInstance()
{
if(_instance == null)
_instance = new Singleton();
return _instance;
}
}