Ejemplo n.º 1
0
        static void Main()
        {
            BitArray64 bits        = new BitArray64(123456789012);
            BitArray64 bitsTwo     = new BitArray64(012345678912);
            BitArray64 anotherBits = new BitArray64(123456789012);

            Console.WriteLine(bits);
            Console.WriteLine(bitsTwo);
            Console.WriteLine(anotherBits);
            Console.WriteLine("Are equals: {0}", bits == anotherBits);
            Console.WriteLine("Change bits: ");
            Console.WriteLine("before: {0}", bits);

            bits[43] = 1;
            bits[44] = 1;
            bits[45] = 1;
            bits[46] = 1;
            bits[47] = 1;
            bits[48] = 1;

            Console.WriteLine("after: {0}", bits);

            Console.WriteLine("Are different: {0}", bits != bitsTwo);
            Console.WriteLine("Are equals: {0}", bits.Equals(bitsTwo));
            Console.WriteLine("Are equals: {0}", bits == bitsTwo);
            Console.WriteLine("Are equals: {0}", bits == anotherBits);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            var testNumber = new BitArray64(254);

            // number as array of bits:
            Console.WriteLine(string.Join("", testNumber.BitArray));

            // check indexer
            Console.WriteLine(testNumber[60]);
            Console.WriteLine(testNumber[5]);

            // check enumerator
            foreach (var bit in testNumber)
            {
                Console.Write(bit);
            }
            Console.WriteLine();

            //check equals and ==
            var testNumber2 = new BitArray64(254);
            var testNumber3 = new BitArray64(122);

            Console.WriteLine(testNumber.Equals(testNumber2));
            Console.WriteLine(testNumber.Equals("11111110"));
            Console.WriteLine(testNumber.Equals(testNumber3));
            Console.WriteLine(testNumber == testNumber2);
            Console.WriteLine(testNumber != testNumber3);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            BitArray64 array = new BitArray64();

            array[0] = 1;
            BitArray64 anotherArray = new BitArray64(1);

            Console.WriteLine(array.Equals(anotherArray));
        }
Ejemplo n.º 4
0
 // Printing some array with foreach
 private static void PrintArray(BitArray64 array1, string text)
 {
     Console.Write(text);
     foreach (var bit in array1)
     {
         Console.Write(bit);
     }
     Console.WriteLine();
 }
Ejemplo n.º 5
0
        static void Main()
        {
            BitArray64 number = new BitArray64();

            number[63] = 1;
            number[8]  = 1;
            number[34] = 1;
            number[45] = 1;

            Console.WriteLine(number);
        }
Ejemplo n.º 6
0
        static void Main()
        {
            var numbers = new BitArray64(254);

            Console.WriteLine(string.Join("", numbers.BitArray));
            Console.WriteLine(numbers[26]);

            numbers.Print();

            var sampleNumber = new BitArray64(254);

            Console.WriteLine(numbers.Equals(sampleNumber));
            Console.WriteLine(numbers.Equals("11111110"));
            Console.WriteLine(numbers == sampleNumber);
        }
 //Equals(...)
 public override bool Equals(object obj)
 {
     if (obj is BitArray64)
     {
         BitArray64 param = obj as BitArray64;
         if (this.array == param.array)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         throw new ArgumentException("Argument is invalid type");
     }
 }
Ejemplo n.º 8
0
        static void Main()
        {
            // Creating two variables of type BitArray64
            const ulong number = 12345678901234567890;
            BitArray64  array1 = new BitArray64(number);
            BitArray64  array2 = new BitArray64(number / 2);

            // Printing the arrays
            PrintArray(array1, "array1: ");
            PrintArray(array2, "array2: ");

            // Comparing both arrays
            Console.WriteLine("\n{0,-24} →  {1}", "array1.Equals(array2)", array1.Equals(array2));
            Console.WriteLine("{0,-24} →  {1}\n", "array1 != array2", array1 != array2);

            // Testing ToString() method
            Console.WriteLine(array1);

            // Testing the indexer
            Console.WriteLine("array1[7] = {0}", array1[7]);
        }