class Person { private static Person persons; public static Person Persons { get{ if (persons==null) { persons = new Person(); } return persons; } } private static Person(){ } }
用单例设计模式,这个Person类有且只能有一个对象,person ,你只能调用我的person,没法自己new