class OS private static OS instance public string Name get private set

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class OS
{
private static OS instance;
public string Name { get; private set; }
private static object syncRoot = new Object();
protected OS(string name)
{
this.Name = name;
}
public static OS getInstance(string name)
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
instance = new OS(name);
}
}
return instance;
}
}