单例模式
public class Singleton
{
private static Singleton instance;
public static Singleton Instance{
get
{
if (instance==null)
{
instance = new Singleton();
}
return instance;
}
}
}
观察者模式
public delegate void CustomerEventHandler();
public class Customer
{
public static event CustomerEventHandler Update;
public void Notify()
{
if (Update != null)
{
Update();
}
}
}
public class ObserverTest
{
ObserverTest()
{
Customer.Update += Fun;
}
void Fun()
{ }
}