Design Pattern 5-MEMENTO

xiaoxiao2021-03-06  63

Using system;

Namespace Pattern {///

/// summary description for class1. /// public class memento {public int number; public string file = "; public memory {numler = m. Number; file = m.file;}} public class originator {public string file = ""; public originator () {} // creates a MEMENTO PUBLIC Memento getMEMEMEMEMEMEMETINTO () NEW MEMENTO (this);} // Restore to the original value public void setmemento (memento m) {Number = m.Number; file = m.file;}

}} // Memo Originator o = new Originator (); o.file = "old file"; =umber = 100; memento m = o.getMemento (); o.file = "new file"; nr = 2100; O.SetMemento (M); console.writeLine (o.file);

转载请注明原文地址:https://www.9cbs.com/read-113103.html

New Post(0)