class Program
{
static void Main(string[] args)
{
origination o=new origination();
o.State = "on";
Memo m=new Memo(o.State);
o.showState();
o.State = "off";
o.showState();
o.BackOut(m);
o.showState();
Console.ReadKey();
}
}
public class origination
{
private string state;
public string State
{
get { return state; }
set { state = value; }
}
public void BackOut(Memo Memo)
{
State = Memo.State;
}
public void showState()
{
Console.WriteLine(State);
}
}
public class Memo
{
private string _state;
public string State
{
get { return _state; }
}
public Memo(string state)
{
this._state=state;
}
}
用一句行话来说就是:你这是既当裁判员,又当运动员。
松耦合