public class Singleton private static readonly Lazy Singleton lazy new

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public class Singleton
{
private static readonly Lazy<Singleton> lazy =
new Lazy<Singleton>(() => new Singleton());
public string Name { get; private set; }
private Singleton()
{
Name = System.Guid.NewGuid().ToString();
}
public static Singleton GetInstance()
{
return lazy.Value;
}
}