随笔分类 -  设计模式

设计模式_状态模式_C#
摘要:public class Context { private State state; public State State { get { return state; } set { state = value; } } public Context(State state) { this.state = state; } /// /// /// public ... 阅读全文

posted @ 2013-09-09 17:37 wulumtoo 阅读(207) 评论(0) 推荐(0)

策略模式_C#_设计模式
摘要:abstract class Strategy { public abstract void IsStrategy(); } class StrategyA : Strategy { public override void IsStrategy() { Console.WriteLine("IsStrategyA"); } } class StrategyB : Strategy { public override void IsStrategy() ... 阅读全文

posted @ 2013-08-13 00:11 wulumtoo 阅读(196) 评论(0) 推荐(0)

单例模式_C#设计模式
摘要:public class Single { private static readonly object obj = new object(); private static Single single; private Single(){ }//防止在类外实例化 public static Single GetSingle() { if (single == null) { lock (obj)//加锁防止某一时间片内有两个线程相继去实例化 ... 阅读全文

posted @ 2013-05-24 23:56 wulumtoo 阅读(117) 评论(0) 推荐(0)

简单工厂模式_C#_设计模式
摘要:基类: 1 public class Operation 2 { 3 private int _numberA = 0; 4 private int _numberB = 0; 5 public int numberA 6 { 7 get { return _numberA; } 8 set { _numberA = value; } 9 }10 public int numberB11 {12 get ... 阅读全文

posted @ 2013-05-20 00:15 wulumtoo 阅读(165) 评论(0) 推荐(0)

导航