예제 #1
0
        static void Main(string[] args)
        {
            BitArray64 testOne = new BitArray64(16777225);
            BitArray64 testTwo = new BitArray64(1);
            BitArray64 testThree = new BitArray64(9);

            //Print all the number
            Console.WriteLine("testOne = {0}, testTwo = {1}, testThree = {2}\n", testOne, testTwo, testThree);

            //Comapre first two and second two
            Console.WriteLine("testOne == testTwo ? {0}", testOne == testTwo);

            Console.WriteLine("testTwo equals testThree ? {0}\n", testTwo.Equals(testThree));

            //Making the number  9 -> 1001
            testTwo[3] = 1;
            //Change, print and check again
            Console.WriteLine("testOne = {0}, testTwo = {1}, testThree = {2}", testOne, testTwo, testThree);
            Console.WriteLine("testTwo equals testThree ? {0}\n", testTwo.Equals(testThree));

            //Making the 24th bit 0, print and compare if NOT EQUAL
            testOne[24] = 0;
            Console.WriteLine("testOne = {0}, testTwo = {1}, testThree = {2}", testOne, testTwo, testThree);
            Console.WriteLine("testOne != (NOT EQUAL) testTwo ? {0}", testOne != testTwo);
        }
예제 #2
0
 static void Main()
 {
     ulong number = 5;
     BitArray64 bit64 = new BitArray64(number);
     // Index test
     Console.WriteLine("Index test:");
     bit64[62] = 1;
     Console.WriteLine(bit64.ToString());
     //Console.WriteLine();
     //Equals method test
     Console.WriteLine("Equals method test");
     Console.WriteLine("7 equals 7 = {0}", bit64.Equals(new BitArray64(7ul)));
     Console.WriteLine("7 equals 9 = {0}", bit64.Equals(new BitArray64(9ul)));
     Console.WriteLine();
     //GetHashCode() test
     Console.WriteLine("GetHashCode() = {0}", bit64.GetHashCode());
     Console.WriteLine();
     // == and != test
     Console.WriteLine("== and != test");
     Console.WriteLine("7 == 7 = {0}", bit64 == new BitArray64(7ul));
     Console.WriteLine("7 != 7 = {0}", bit64 != new BitArray64(7ul));
     Console.WriteLine("7 != 9 = {0}", bit64 != new BitArray64(9ul));
     Console.WriteLine("7 == 9 = {0}", bit64 == new BitArray64(9ul));
     Console.WriteLine();
     //IEnumerable test
     Console.WriteLine("IEnumerable test");
     foreach (var bit in bit64)
     {
         Console.Write(bit);
     }
     Console.WriteLine();
 }
예제 #3
0
        public 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);
        }
        static void Main()
        {
            var number1 = new BitArray64(22L);
            var number2 = new BitArray64(33L);

            number2[62] = 1;

            Console.WriteLine("number2[62] = {0}", number2[62]);
            Console.WriteLine();

            foreach (var bit in number1)
            {
                Console.Write(bit);
            }
            Console.WriteLine();
            Console.WriteLine(number2);

            Console.WriteLine();

            Console.WriteLine(number1.GetHashCode());
            Console.WriteLine(number2.GetHashCode());

            Console.WriteLine();

            Console.WriteLine("number1 == number2 : {0}", number1 == number2);
            Console.WriteLine("number1 != number2 : {0}", number1 != number2);
            Console.WriteLine("number1.Equals(number1) : {0}", number1.Equals(number1));
            Console.WriteLine("number1.Equals(number2) : {0}", number1.Equals(number2));
        }
예제 #5
0
        static void Main()
        {
            Console.WriteLine("----- Show foreach result -----");
            BitArray64 testBitArray = new BitArray64(8);
            foreach (var item in testBitArray)
            {
                Console.Write(item);
            }

            Console.WriteLine("\n----- Show Equals result -----");
            BitArray64 firstBitArray = new BitArray64(10);
            BitArray64 secondBitArray = new BitArray64(11);
            BitArray64 thirdBitArray = new BitArray64(10);
            Console.WriteLine("firstBitArray.Equals(secondBitArray): {0}",firstBitArray.Equals(secondBitArray));
            Console.WriteLine("firstBitArray.Equals(thirdBitArray): {0}", firstBitArray.Equals(thirdBitArray));
            Console.WriteLine("secondBitArray.Equals(thirdBitArray): {0}", secondBitArray.Equals(thirdBitArray));

            Console.WriteLine("\n----- Show hash code -----");
            Console.WriteLine("Hash code of firstBitArray is: {0}", firstBitArray.GetHashCode());
            Console.WriteLine("Hash code of secondBitArray is: {0}", secondBitArray.GetHashCode());

            Console.WriteLine("\n----- Show operator [] -----");
            for (int i = 0; i < testBitArray.Count(); i++)
            {
                Console.Write(testBitArray[i]);
            }

            Console.WriteLine("\n----- Show operators == and != -----");
            Console.WriteLine("firstBitArray == secondBitArray : {0}", firstBitArray == secondBitArray);
            Console.WriteLine("firstBitArray == thirdBitArray : {0}", firstBitArray == thirdBitArray);
            Console.WriteLine("firstBitArray != secondBitArray : {0}", firstBitArray != secondBitArray);
            Console.WriteLine("firstBitArray != thirdBitArray : {0}", firstBitArray != thirdBitArray);
        }
예제 #6
0
        static void Main()
        {
            BitArray64 number1 = new BitArray64(5);
            BitArray64 number2 = new BitArray64(5);
            Console.WriteLine(String.Join("",number1.BitArray));

            //Test indexer
            Console.WriteLine(number1[0]);
            number1[3] = 1;

            //Test Equals
            Console.WriteLine(number1 == number2);

            //Test "=="
            Console.WriteLine(number1.Equals(number2));

            //Test enumerator
            foreach (var item in number1)
            {
                Console.Write(item);
            }

            //Test GetHashCode
            Console.WriteLine(number1.GetHashCode());
            Console.WriteLine(number1.GetHashCode());
        }
예제 #7
0
    static void Main()
    {
        BitArray64 num = new BitArray64(99);

        foreach (var bit in num)
        {
            Console.Write(bit);
        }
        Console.WriteLine();

        BitArray64 number2 = new BitArray64(7);

        Console.WriteLine(num.Equals(number2));

        Console.WriteLine(num[2]);

        Console.WriteLine(num.GetHashCode());

        num[8] = 1;
        num[50] = 1;

        Console.WriteLine(num.Number);
        foreach (var bit in num)
        {
            Console.Write(bit);
        }
        Console.WriteLine();
    }
 static void Main(string[] args)
 {
     BitArray64 array = new BitArray64();
     array[0] = 1;
     BitArray64 anotherArray = new BitArray64(1);
     Console.WriteLine(array.Equals(anotherArray));
 }
예제 #9
0
        static void Main()
        {
            BitArray64 someNumber = new BitArray64(15);
            BitArray64 otherNumber = new BitArray64(150);
            //chech IEnumerable
            StringBuilder str = new StringBuilder();
            foreach (var bit in someNumber)
            {

                str.Append(bit);
            }
            string bitReperentation = str.ToString();

            char[] arrayBits = bitReperentation.ToCharArray();
            Array.Reverse(arrayBits);
            string finalBitRep = new string(arrayBits);
            finalBitRep = finalBitRep.TrimStart('0');
            Console.WriteLine(finalBitRep);
            //check equals and hashcode
            Console.WriteLine(someNumber.Equals(otherNumber));
            Console.WriteLine(someNumber.GetHashCode());
            Console.WriteLine(otherNumber.GetHashCode());

            //chech == and !=
            Console.WriteLine(someNumber==otherNumber);
            Console.WriteLine(someNumber!=otherNumber);
        }
        static void Main(string[] args)
        {
            BitArray64 num = new BitArray64(2345678);
            //check the bits
            Console.WriteLine(string.Join("", num.ArrayBits));
            //check index
            Console.WriteLine(num[63]);
            Console.WriteLine(num[62]);
            Console.WriteLine(num[0]);
            //check enumeratora

            foreach (var bit in num)//тук само числото слагаме, за да видим дали сме му сложили foreacha
            {
                //оставила съм го да събира номера на 1 или 0 от аски таблица с 200, за да се види ясно!
                Console.WriteLine(bit);
            }

            //вграден форич за масив
               foreach (var bit in num.ArrayBits)
               {
               //tuk si izpisva 4isloto normalno
               Console.Write(bit);
               }
               Console.WriteLine();

            // check equals

               BitArray64 anothernum = new BitArray64(234567);
               Console.WriteLine(num.Equals(anothernum));

            //chech operators == and =!
               Console.WriteLine(num == anothernum);
               Console.WriteLine(num != anothernum);
        }
        static void Main(string[] args)
        {
            BitArray64 number = new BitArray64(7);

            // print bits of the ulong number
            foreach (var bit in number)
            {
                Console.Write(bit);
            }
            Console.WriteLine();

            // make second BitArray
            BitArray64 number2 = new BitArray64(7);

            Console.WriteLine(number.Equals(number2));

            // indexer starts from young bits
            Console.WriteLine(number[2]);
            // print hash code
            Console.WriteLine(number.GetHashCode());

            // change bit
            number[4] = 1;
            // print the changed number and his bits
            Console.WriteLine(number.Number);
            foreach (var bit in number)
            {
                Console.Write(bit);
            }
            Console.WriteLine();
        }
        public static void Main()
        {
            BitArray64 bits = new BitArray64(123456789999);
            Console.WriteLine(string.Join("", bits));
            Console.WriteLine("Hash code: {0}", bits.GetHashCode());

            BitArray64 anotherBits = new BitArray64(123456789999);
            Console.WriteLine(string.Join("", anotherBits));
            Console.WriteLine("Hash code: {0}", anotherBits.GetHashCode());

            Console.WriteLine("Equals: {0}", bits.Equals(anotherBits));
            Console.WriteLine(" == {0}", bits == anotherBits);
            Console.WriteLine(" != {0}", bits != anotherBits);

            Console.WriteLine("Foreach:");
            foreach (var bit in bits)
            {
                Console.Write(bit);
            }

            Console.WriteLine();

            Console.WriteLine("For:");
            for (int i = 0; i < bits.Bits.Length; i++)
            {
                Console.Write(bits.Bits[i]);
            }

            Console.WriteLine();
        }
        static void Main()
        {
            BitArray64 arr = new BitArray64(5);
            BitArray64 arr1 = new BitArray64(5);

            arr1[0] = 6;
            arr[0] = 4;

            Console.WriteLine("Use foreach.");
            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }

            Console.Write("\narr Equals arr1: ");
            Console.WriteLine(arr.Equals(arr1));

            Console.WriteLine("\nThe arr HashCode is {0}", arr.GetHashCode());

            Console.WriteLine("\narr == arr1: {0}", arr == arr1);

            Console.WriteLine("\narr != arr1: {0}", arr != arr1);

            Console.WriteLine("\narr: {0}", arr);
            Console.WriteLine("arr1: {0}", arr1);
        }
예제 #14
0
    // Define a class BitArray64 to hold 64 bit values inside an ulong value.
    // Implement IEnumerable<int> and Equals(…), GetHashCode(), [], == and !=.
    internal static void Main()
    {
        // Let's use int.MaxValue (32 one's) to set the BitArray64
        BitArray64 bitArray1 = new BitArray64(int.MaxValue);

        // Use IEnumerable to foreach the elements in the BitArray64
        Console.Write("bitArray1: ");
        foreach (var bit in bitArray1)
        {
            Console.Write(bit);
        }

        // Use BitArray64.ToString to print the second bitarray
        BitArray64 bitArray2 = new BitArray64(int.MaxValue - 1);
        Console.WriteLine("\nbitArray2: {0}", bitArray2);

        // Test BitArray64.Equals, ==, !=
        Console.WriteLine();
        Console.WriteLine("bitArray1.Equals(bitArray2) -> {0}", bitArray1.Equals(bitArray2));
        Console.WriteLine("(bitArray1 == bitArray2) -> {0}", bitArray1 == bitArray2);
        Console.WriteLine("(bitArray1 != bitArray2) -> {0}", bitArray1 != bitArray2);

        // Test BitArray64.GetHashCode
        Console.WriteLine();
        Console.WriteLine("bitArray1 HashCode: {0}", bitArray1.GetHashCode());
        Console.WriteLine("bitArray2 HashCode: {0}", bitArray2.GetHashCode());

        // Test indexers
        Console.WriteLine();
        Console.WriteLine("bitArray1[0] = {0}", bitArray1[0]);
        Console.WriteLine("bitArray2[0] = {0}", bitArray2[0]);
    }
        static void Main()
        {
            Console.WriteLine("New BitArray64 bitArray1 (ulong as constuctor parameter):");
            BitArray64 bitArray1 = new BitArray64(25);
            Console.WriteLine(bitArray1);

            Console.WriteLine("New BitArray64 bitArray2 (string represented bynary number as constuctor parameter):");
            BitArray64 bitArray2 = new BitArray64("11001");
            Console.WriteLine(bitArray2);
            Console.WriteLine();

            Console.WriteLine("print foreach");

            foreach (var item in bitArray2)
            {
                Console.Write(item);
                Console.Write('\t');
            }

            Console.WriteLine();

            Console.WriteLine("Bit at position {0} = {1}", 3, bitArray2[3]);
            Console.WriteLine();

            Console.WriteLine("bitArray1 eaquals to bitArray2? {0}", bitArray1.Equals(bitArray2));
            Console.WriteLine("bitArray1 == bitArray2? {0}", bitArray1 == bitArray2);
            Console.WriteLine("bitArray1 != bitArray2? {0}", bitArray1 != bitArray2);
            Console.WriteLine();

               Console.WriteLine("Hash code: {0}", bitArray1.GetHashCode());
        }
        static void Main()
        {
            BitArray64 arrayOne= new BitArray64(3u);
            BitArray64 arrayTwo = new BitArray64(150u);

            Console.WriteLine("Binary number one:");
            Console.WriteLine(arrayOne);
            Console.WriteLine("Binary number two:");
            Console.WriteLine(arrayTwo);

            arrayOne[0] = 0;
            arrayTwo[0] = 1;

            Console.WriteLine("Binary number one changed:");
            Console.WriteLine(arrayOne);
            Console.WriteLine("Binary number two changed:");
            Console.WriteLine(arrayTwo);

            Console.WriteLine("\nNumber one == number two?");
            Console.WriteLine(arrayOne == arrayTwo);

            Console.WriteLine("\nNumber one is equal to itself?");
            Console.WriteLine(arrayOne.Equals(arrayOne));

            Console.WriteLine("\nNumber one !- number two?");
            Console.WriteLine(arrayOne != arrayTwo);

            Console.WriteLine("\nThe bit with index [2] of number one is:");
            Console.WriteLine(arrayOne[2]);

            Console.WriteLine("\nThe bit with index [2] of number two is:");
            Console.WriteLine(arrayTwo[2]);
        }
예제 #17
0
파일: Test.cs 프로젝트: nexusstar/Telerik
        static void Main()
        {
            BitArray64 bitOne = new BitArray64(123456);

            BitArray64 bitTwo = new BitArray64(88888888888);

            BitArray64 bitMaxValue = new BitArray64(ulong.MaxValue);

            Console.WriteLine(bitOne); //test toString() and compare to foreach
            foreach (var bit in bitOne)//test foreach
            {
                Console.Write(bit);
            }

            Console.WriteLine();

            Console.WriteLine(bitTwo);
            Console.WriteLine(bitMaxValue); //test ulong max value

            Console.WriteLine(bitOne.Equals(bitTwo));

            Console.WriteLine(bitOne != bitTwo);

            Console.WriteLine(bitOne.GetHashCode());

            Console.WriteLine(bitTwo.GetHashCode());
        }
    static void Main()
    {
        int numInt = 123456789;
        Console.WriteLine(Convert.ToString(numInt, 2).PadLeft(64, '0'));

        ulong numUlong = 123456789;
        BitArray64 bits = new BitArray64(numUlong);

        foreach (var bit in bits)
        {
            Console.Write(bit);
        }
        Console.WriteLine();
        Console.WriteLine();

        BitArray64 bits2 = new BitArray64((ulong)8766);
        Console.WriteLine(bits.Equals(bits2));
        Console.WriteLine(bits == bits2);
        Console.WriteLine(bits != bits2);
        Console.WriteLine();

        Console.WriteLine(bits);

        Console.WriteLine(bits[0]);

        Console.WriteLine();
    }
예제 #19
0
    public static void Main()
    {
        // Initializing data types
        BitArray64 num1 = new BitArray64(212);
        BitArray64 num2 = new BitArray64(212);

        // Testing indexer
        int index = 7;
        Console.WriteLine("The bit at position {0} is:", index);
        Console.WriteLine(num1[index] + "\n");

        // Testing enumaration
        Console.WriteLine("Enumeration");
        foreach (var item in num1)
        {
            Console.Write(item);
        }

        Console.WriteLine();

        // Testing ToString()
        Console.WriteLine("\nToString()");
        Console.WriteLine(num1);

        // Testing comparing
        Console.WriteLine("num1 Equals num2 --> {0}", num1.Equals(num2));
        Console.WriteLine("num1 == num2 --> {0}", num1 == num2);
        Console.WriteLine("num1 != num2 --> {0}", num1 != num2);
    }
예제 #20
0
 static void Main()
 {
     //Print some number in binary representation just to compare with it
     int num = 9578;
     Console.WriteLine(Convert.ToString(num, 2).PadLeft(64, '0'));
     //Making the BitArray64 with the same number but from ulong type
     ulong number = 9587;
     BitArray64 bits = new BitArray64(number);
     //Test foreach
     foreach (var bit in bits)
     {
         Console.Write(bit);
     }
     Console.WriteLine();
     Console.WriteLine("-----------------------------------------------------------------");
     //Making new BitArray64 and compare it with the old one
     BitArray64 bits2 = new BitArray64((ulong)8766);
     Console.WriteLine(bits.Equals(bits2));
     Console.WriteLine(bits == bits2);
     Console.WriteLine(bits != bits2);
     Console.WriteLine("-----------------------------------------------------------------");
     //Test ToString() method
     Console.WriteLine(bits);
     //Test overriten operator[]
     Console.WriteLine(bits[0]);
 }
    static void Main()
    {
        BitArray64 bitArrayOne = new BitArray64(9999);
        Console.WriteLine("First number:");
        foreach (var bit in bitArrayOne)
        {
            Console.Write(bit);
        }
        Console.WriteLine();

        BitArray64 bitArrayTwo = new BitArray64(8888);
        Console.WriteLine("\nSecond number:");
        foreach (var bit in bitArrayTwo)
        {
            Console.Write(bit);
        }
        Console.WriteLine("\n");

        Console.WriteLine("---------------Test Equals() method-----------------");
        Console.WriteLine(bitArrayOne.Equals(bitArrayTwo));
        Console.WriteLine(bitArrayOne == bitArrayTwo);
        Console.WriteLine(bitArrayOne != bitArrayTwo);
        Console.WriteLine();

        Console.WriteLine("---------------Test ToString() method-----------------");
        Console.WriteLine(bitArrayOne);
        Console.WriteLine("\n---------------Test overriden operator []-----------------");
        Console.WriteLine(bitArrayOne[0]);
        Console.WriteLine(bitArrayTwo[0]);

        Console.WriteLine("\n---------------Test GetHashCode() method-----------------");
        Console.WriteLine(bitArrayOne.GetHashCode());
        Console.WriteLine(bitArrayTwo.GetHashCode());
        Console.WriteLine();
    }
예제 #22
0
        static void Main()
        {
            ulong uLongNumber1 = 888;
            BitArray64 number = new BitArray64(uLongNumber1);

            Console.WriteLine("Bits of the number {0}", uLongNumber1);
            foreach (var bit in number)
            {
                Console.Write(bit);
            }
            Console.WriteLine();
            Console.WriteLine("Bit at position 60 is {0}", number[60]);
            Console.WriteLine("Hash code of {0} is {1}", uLongNumber1, number.GetHashCode());

            ulong uLongNumber2 = 123456789;
            BitArray64 otherNumber = new BitArray64(uLongNumber2);
            Console.WriteLine("\nBits of the number {0}", uLongNumber2);
            foreach (var bit in otherNumber)
            {
                Console.Write(bit);
            }
            Console.WriteLine();

            Console.WriteLine("\n{0} == {1} ? {2}", uLongNumber1, uLongNumber2, number == otherNumber);
            Console.WriteLine("\n{0} != {1} ? {2}", uLongNumber1, uLongNumber2, number != otherNumber);
            Console.WriteLine("\n{0} equals {1} ? {2}\n", uLongNumber1, uLongNumber2, number.Equals(otherNumber));
        }
예제 #23
0
        public static void Main()
        {
            BitArray64 oneValue = new BitArray64(10u);
            BitArray64 secondValue = new BitArray64(10u);
            BitArray64 thirdValue = new BitArray64(20u);

            Console.WriteLine("oneValue equals secondValue: {0}",oneValue.Equals(secondValue));
            Console.WriteLine("oneValue equals thirdValue: {0}", oneValue.Equals(thirdValue));
            Console.WriteLine();
            Console.WriteLine("oneValue == secondValue: {0}", oneValue==secondValue);
            Console.WriteLine("oneValue == thirdValue: {0}", oneValue == thirdValue);
            Console.WriteLine("oneValue != thirdValue: {0}", oneValue!=thirdValue);
            Console.WriteLine("oneValue == secondValue: {0}", oneValue != secondValue);
            Console.WriteLine();
            Console.WriteLine("oneValue.GetHashCode: {0}",oneValue.GetHashCode());
            Console.WriteLine();
        }
예제 #24
0
파일: Program.cs 프로젝트: abaditsegay/SVN
    static void Main(string[] args)
    {
        BitArray64 bits = new BitArray64(8);
        foreach (var bit in bits)
        {
            Console.Write(bit);
        }
        Console.WriteLine();

        //checking equals
        Console.WriteLine(bits.Equals(new BitArray64(9))); //False
        Console.WriteLine(bits.Equals(8)); //False (not the same type)

        //checking operators == and !=
        Console.WriteLine(bits==new BitArray64(8));     //true
        Console.WriteLine(bits== new BitArray64(9));    //false
        Console.WriteLine(bits!= new BitArray64(10));   //true
    }
예제 #25
0
 static void Main()
 {
     // Testing the class
     BitArray64 bitArr = new BitArray64(32);
     // Changing values
     Console.WriteLine(bitArr[5]);
     bitArr[5] = 0;
     Console.WriteLine(bitArr[5]);
     bitArr[5] = 1;
     BitArray64 bitArray = new BitArray64(32);
     BitArray64 bitArrayThree = new BitArray64(64);
     // Should be equal
     Console.WriteLine(bitArr.Equals(bitArray));
     // Should not be equal
     Console.WriteLine(bitArr.Equals(bitArrayThree));
     // Testing ToString
     Console.WriteLine(bitArr);
     Console.WriteLine(bitArrayThree);
 }
예제 #26
0
        static void Main()
        {
            string decorationLine = new string('-', 80);
            Console.Write(decorationLine);
            Console.WriteLine("***Testing BitArray64 functionality***");
            Console.Write(decorationLine);

            // Creating some bit arrays
            BitArray64 bitArray1 = new BitArray64(9152658268616102156UL);
            BitArray64 bitArray2 = new BitArray64(51251861512UL);

            Console.WriteLine("---Printing the bits from two bit arrays---");
            Console.WriteLine("The representation of {0} as bit array is:", 9152658268616102156UL);
            Console.WriteLine(bitArray1);
            Console.WriteLine("The representation of {0} as bit array is:", 51251861512UL);
            Console.WriteLine(bitArray2);

            Console.WriteLine("---Testing the implementation of IEnumerable<int> interface methods---");
            int onesCount = 0;
            foreach (int bit in bitArray1)
            {
                if (bit == 1)
                {
                    onesCount++;
                }
            }
            Console.WriteLine("The bits 1 in the first bit array are: " + onesCount);
            int zeroesCount = 0;
            foreach (int bit in bitArray2)
            {
                if (bit == 0)
                {
                    zeroesCount++;
                }
            }
            Console.WriteLine("The bits 0 in the second bit array are: " + zeroesCount);
            Console.WriteLine();

            Console.WriteLine("---Testing the methods Equals() and GetHashCode()---");
            Console.WriteLine("First bit array equals second one: " + bitArray1.Equals(bitArray2));
            Console.WriteLine("Hash code of second bit array: " + bitArray2.GetHashCode());
            Console.WriteLine();

            Console.WriteLine("---Testing the indexer over the second bit array---");
            Console.WriteLine("bit at index 11 -> " + bitArray2[11]);
            Console.WriteLine("bit at index 38 -> " + bitArray2[38]);
            Console.WriteLine("bit at index 63 -> " + bitArray2[63]);
            Console.WriteLine();

            Console.WriteLine("---Testing equality and inequality operators---");
            Console.WriteLine("The first bit array is equal to the second one -> " + (bitArray1 == bitArray2));
            Console.WriteLine("The first bit array is different from the second one -> " + (bitArray1 != bitArray2));
        }
예제 #27
0
    static void Main(string[] args)
    {
        // TASK 4
        BitArray64 num1 = new BitArray64(15);
        BitArray64 num2 = new BitArray64(1);
        Console.WriteLine(num1.Equals(num2));
        Console.WriteLine(num1 == num2);
        Console.WriteLine(num1 != num2);

        int bit = num1[4];
        Console.WriteLine(bit);
    }
예제 #28
0
        static void Main()
        {
            BitArray64 firstTestArr = new BitArray64(3);
            Console.WriteLine(firstTestArr);
            Console.WriteLine(firstTestArr.GetHashCode());

            BitArray64 secondTestArr = new BitArray64(3);
            Console.WriteLine(secondTestArr);
            Console.WriteLine(secondTestArr.GetHashCode());

            Console.WriteLine(firstTestArr.Equals(secondTestArr));
            Console.WriteLine(firstTestArr != secondTestArr);
        }
 static void Main(string[] args)
 {
     BitArray64 ba = new BitArray64(50);
     BitArray64 ba2 = new BitArray64(50);
     for (int i = 0; i < ba.Length; i++)
     {
         ba[i] = (ulong)i;
         ba2[i] = (ulong)i;
     }
     Console.WriteLine(ba.Equals(ba2));
     Console.WriteLine(ba == ba2);
     Console.WriteLine(ba != ba2);
 }
        static void Main(string[] args)
        {
            BitArray64 userTestInputOne = new BitArray64(5643);
            BitArray64 userTestInputTwo = new BitArray64(4356);
            BitArray64 userTestInputThree = new BitArray64(5643);

            bool testOne = userTestInputOne.Equals(userTestInputTwo);
            bool testTwo = userTestInputOne.Equals(userTestInputThree);
            int testHashCode = userTestInputOne.GetHashCode();
            int testIndexOne = userTestInputOne[62];
            int testIndexTwo = userTestInputOne[61];
            bool testThree = userTestInputOne == userTestInputTwo;

            Console.WriteLine(userTestInputOne.Value);
            Console.WriteLine(userTestInputOne.ToString());
            Console.WriteLine(testOne);
            Console.WriteLine(testTwo);
            Console.WriteLine(testThree);
            Console.WriteLine(testHashCode);
            Console.WriteLine(testIndexOne);
            Console.WriteLine(testIndexTwo);
        }
예제 #31
0
 public static bool operator !=(BitArray64 arrayA, BitArray64 arrayB)
 {
     return(!(BitArray64.Equals(arrayA, arrayB)));
 }
예제 #32
0
 public static bool operator !=(BitArray64 first, BitArray64 second)
 {
     return(!BitArray64.Equals(first, second));
 }
예제 #33
0
 public static bool operator !=(BitArray64 a, BitArray64 b)
 {
     return(!BitArray64.Equals(a, b));
 }
예제 #34
0
 public static bool operator ==(BitArray64 bitArray1, BitArray64 bitArray2)
 {
     return(BitArray64.Equals(bitArray1, bitArray2));
 }