Example

 using System; using System.Collections; namespace Samples { public class ICloneableSample: ICloneable { private int i; private Hashtable h; public int AnInteger { get { return i;} set { i = value;} } public Hashtable AHashtable { get { return h;} set { h = value;} } public ICloneableSample() { i = 42; h = new Hashtable(); } private ICloneableSample(int i, Hashtable ht) { this.i = i; h = (Hashtable) ht.Clone(); } public object Clone() { return new ICloneableSample(i, h); } public static void Main() { ICloneableSample i1 = new ICloneableSample(); i1.AHashtable.Add("one", "damien"); ICloneableSample i2 = (ICloneableSample) i1.Clone(); i2.AnInteger = 22; i2.AHashtable.Add("two", "brad"); Console.WriteLine("i1.AnInteger {0} i1.AHashtable.Count ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.