/*
            * BitArray Class is derived from the System.Collections.generics
            * it supports AND,OR ,XOR Opertaions
            * It is used for storing just boolean value.
            * It doesn't have Add or remove method like any another Collections.
            */
            BitArray btArray1 = new BitArray(3);
            btArray1[0] = true;
            btArray1[1] = false;
            btArray1[2] = true;
            BitArray btArray2 = new BitArray(3);
            btArray2[0] = true;
            btArray2[1] = false;
            btArray2[2] = true;
            /*
             * Note : if you want to change the length of the Array just set its length propery.
             * =========================
             * Conditions 1
             * ==============================
                BitArray bitXOR = btArray1.Xor(btArray2);
                foreach (object bit in bitXOR)
                {
                    Console.WriteLine(bit.ToString());
                }
             * o/p: False,false,false
             ==============================
             * Condition 2
             ====================================== 
            BitArray bitXOR = btArray1.And (btArray2);
            foreach (object bit in bitXOR)
            {
                Console.WriteLine(bit.ToString());
            }
             *o/p: True,false,True
             *
           
            BitArray bitXOR = btArray1.Or(btArray2);
            foreach (object bit in bitXOR)
            {
                Console.WriteLine(bit.ToString());
            }
               * o/p: True,false,True
             ==============================
             * Condition 3
             ====================================== 
             
            BitArray bitXOR = btArray1.Not();
            foreach (object bit in bitXOR)
            {
                Console.WriteLine(bit.ToString());
            }
                * o/p: false,true,false
             */
            Console.Read();
No comments:
Post a Comment