public override bool Equals(object obj) { BitArray64 temp = obj as BitArray64; if (temp == null) { return(false); } return(this.Equals(temp)); }
// Equals public bool Equals(BitArray64 value) { if (ReferenceEquals(null, value)) { return(false); } if (ReferenceEquals(this, value)) { return(true); } return(this.number == value.number); }
static void Main(string[] args) { BitArray64 arr = new BitArray64(800); foreach (var item in arr) { Console.Write(item); } BitArray64 arr2 = new BitArray64(256); Console.WriteLine(); Console.WriteLine("Check for equality: {0}", arr.Equals(arr2)); Console.WriteLine("Check for equality: {0}", arr == arr2); Console.WriteLine("Print HashCode arr: " + arr.GetHashCode()); Console.WriteLine("Print HashCode arr2: " + arr2.GetHashCode()); Console.WriteLine("Element at position: " + arr2[62]); }
//!= operator public static bool operator !=(BitArray64 first, BitArray64 second) { return(!BitArray64.Equals(first, second)); }