构造类
1 class God 2 { 3 private static God Instance = new God(); 4 private God() { } 5 6 public void ZhaoYaoDaDi() 7 { 8 Console.WriteLine("照耀大地"); 9 } 10 public static God GetInstace() 11 { 12 return Instance; 13 } 14 }
调用
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 // God d1 = new God(); 6 7 God.GetInstace().ZhaoYaoDaDi(); 8 //God.Instance.ZhaoYaoDaDi(); 9 Console.ReadKey(); 10 11 } 12 }