Example #1
0
        static void Main()
        {
            ulong      number        = 135;
            BitArray64 numberBitsArr = new BitArray64(number);

            ulong      secondNumber     = 3592;
            BitArray64 secondNumBitsArr = new BitArray64(secondNumber);

            Console.WriteLine("Print the bits of the first array:");
            foreach (var bit in numberBitsArr)
            {
                Console.Write(bit);
            }

            Console.WriteLine();
            Console.WriteLine("Print the bits of the second array:");
            Console.WriteLine("{0}", string.Join("", secondNumBitsArr));

            Console.WriteLine();

            BitArray64 thirdArr = new BitArray64(secondNumber);

            Console.WriteLine("Print the bits of the third array:");
            Console.WriteLine("{0}", string.Join("", thirdArr));
            Console.WriteLine();

            Console.WriteLine("Result from comapring the first and second arrays:");
            CheckForEqualityAndPrintResult(numberBitsArr, secondNumBitsArr);

            Console.WriteLine("Result from comapring the second and third arrays:");
            CheckForEqualityAndPrintResult(secondNumBitsArr, thirdArr);
        }
Example #2
0
        private static void CheckForEqualityAndPrintResult(BitArray64 firstArr, BitArray64 secondArr)
        {
            if (firstArr.Equals(secondArr))
            {
                Console.WriteLine("The 2 numbers are equal!");
            }
            else
            {
                Console.WriteLine("The 2 numbers are different!");
            }

            Console.WriteLine();
        }
Example #3
0
        public override bool Equals(object obj)
        {
            if (!(obj is BitArray64))
            {
                return(false);
            }

            BitArray64 otherArr = obj as BitArray64;

            if (otherArr == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, otherArr))
            {
                return(true);
            }

            return(this.Number == otherArr.Number);
        }