CyrusBuilt.MonoPi.BitSet.Clone C# (CSharp) Method

Clone() public method

Creates a new object that is a copy of the current instance.
public Clone ( ) : Object
return Object
		public Object Clone() {
			if (!this._sizeIsSticky) {
				this.TrimToSize();
			}

			try {
				BitSet bs = null;
				IFormatter formatter = new BinaryFormatter();
				using (Stream s = new MemoryStream()) {
					formatter.Serialize(s, this);
					s.Seek(0, SeekOrigin.Begin);
					bs = (BitSet)formatter.Deserialize(s);
				}
				bs._bits = (long[])this._bits.Clone();
				bs.CheckInvariants();
				return bs;
			}
			catch {
				return null;
			}
		}