单例模式
1、Person类里面
class Person { private static Person p; public static Person GetSingle() { if (p == null) { p = new Person(); } return p; } private Person() { } }
2、Program类里面
class Program { static void Main(string[] args) { Person p = Person.GetSingle(); } }