public class Singleton public string Date get private set public stati

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class Singleton
{
public string Date { get; private set; }
public static string text = "hello";
private Singleton()
{
Console.WriteLine($"Singleton ctor {DateTime.Now.TimeOfDay}");
Date = DateTime.Now.TimeOfDay.ToString();
}
public static Singleton GetInstance()
{
Console.WriteLine($"GetInstance {DateTime.Now.TimeOfDay}");
Thread.Sleep(500);
return Nested.instance;
}
private class Nested
{
static Nested() { }
internal static readonly Singleton instance = new Singleton();
}
}