标签:des style blog io color sp div log bs
void Main() { Subject subject = new Subject{ Input = "Hello World" }; (new InterpreterA()).Interprete(subject); subject.Output.Dump(); (new InterpreterB()).Interprete(subject); subject.Output.Dump(); } class Subject{ public string Input { get; set; } public string Output { get; set; } } abstract class Interpreter{ public abstract void Interprete(Subject subject); } class InterpreterA:Interpreter{ public override void Interprete(Subject subject){ subject.Output=subject.Input.ToLower(); } } class InterpreterB:Interpreter{ public override void Interprete(Subject subject){ subject.Output=subject.Input.ToUpper(); } }
DesignPattern_Behavioral_Interpreter
标签:des style blog io color sp div log bs
原文地址:http://www.cnblogs.com/rammderek/p/4103054.html