Twin brothers (Prototype)

zhaozj2021-02-16  45

One day, when you find another time you exist, is it happy or fear? This may violate the ethical guidelines of human beings, but for the objects that can collaborate, if necessary, if necessary, you need to dynamically generate one as yours. It is undoubtedly a good development direction. Maybe you have heard of it. Yes. That is when you don't need to know how to copy it. Just need a proactive creation of the object and get your purpose through the prototype prototype. On .NET Everything is derived from the Object class. This means that the MEMBERWISECLONE method is there from the beginning. So the problem changes in simple .namespace prototypens {using system; interface iprototype {iprototypeclonebody ();}

Class myprototype: iprototype {public iprototype clonebody () {return (iPrototype) Memberwiseclone ();}}

Class Cloney {Private iPrototype IP;

Public void setPrototype (iPrototype OtherP) {ip = Otherp;

Public iPrototype Procedurce () {iprototype xman; xman = ip.clonebody (); return xman;}}

Public class client {public static int main (string [] args) {myprototype clonep; cloned c = new cloned (); myprototype myp = new myprototype (); C.SetPrototype (MYP); clonep = c.Procedurce ();

Return 0;}}}}}}}

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

New Post(0)