吹风

导航

 

学习TerryLee的设计模式颇有感触,留下以下笔记以作日后参考。

代码
//-----------------------------------------------
//Singleton模式要求一个类有且仅有一个实例,并且提供了一个全局的访问点。
//-----------------------------------------------

public class Person
{ }

public sealed class SinglePerson
{
protected static readonly Person person = new Person();

public Person Person
{
get
{
return person;
}
}
}
posted on 2010-12-25 11:38  吹风  阅读(173)  评论(0编辑  收藏  举报