1. Superficial Replication
Public class lowcopy: icloneable
{
Private string _ strb;
Public String strb
{
Get {return _ strb ;}
Set {_ strb = value ;}
}
Public object clone ()
{
Return (object) This. memberwiseclone ();
}
}
Call lowcopy lowcopy1 = new lowcopy () in the main function ();
Lowcopy lowcopy2 = (lowcopy) lowcopy1.clone ();
2. Deep Replication
Public class lowcopy: icloneable
{
Private string _ strb;
Public String strb
{
Get {return _ strb ;}
Set {_ strb = value ;}
}
Public object clone ()
{
Return (object) This. memberwiseclone ();
}
}
Public class higthcopy: icloneable
{
Private string _ strhight;
Private lowcopy;
Public hightcopy ()
{Lowcopy = new lowcopy ();}
Public object clone ()
{
Hightcopy Hc = new hightcopy ();
HC. lowcopy = (lowcopy) This. lowcopy. memberwiseclone ();
HC. _ strhight = This. _ strhight;
Return (object) HC;
}
}