public void Main() { var s = new ConcretePrototype1("id"); ((ProtoType)s).Idd(); //访问父类被隐藏的Idd方法 s.Idd(); //默认访问新类的Idd方法 var sClone = s.Clone(); }
static void Main() { // Create two instances and clone each ConcretePrototype1 p1 = new ConcretePrototype1("I"); ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone(); Console.WriteLine("Cloned: {0}", c1.Id); ConcretePrototype2 p2 = new ConcretePrototype2("II"); ConcretePrototype2 c2 = (ConcretePrototype2)p2.Clone(); Console.WriteLine("Cloned: {0}", c2.Id); // Wait for user Console.Read(); }
public void Main() { var s = new ConcretePrototype1("id"); ((ProtoType) s).Idd();//访问父类被隐藏的Idd方法 s.Idd();//默认访问新类的Idd方法 var sClone=s.Clone(); }