BitArray : BitArray : Data Structure C# Examples


C# Examples » Data Structure » BitArray »

 

BitArray









    
using  System;  
using  System.Collections;  
  
class  MainClass  {  
    public  static  void  Main()  {  
        BitArray  ba  =  new  BitArray(8);  
        byte[]  b  =  {  67  };  
        BitArray  ba2  =  new  BitArray(b);  
          
        Console.WriteLine("Original  contents  of  ba:");  

        for(int  i=0;  i  <  ba.Count;  i++)  
            Console.Write("{0,  -6}  ",  ba[i]);  

        ba  =  ba.Not();  
  
        BitArray  ba3  =  ba.Xor(ba2);  
  
        Console.WriteLine("Result  of  ba  XOR  ba2:");  
        for(int  i=0;  i  <  ba3.Count;  i++)  
            Console.Write("{0,  -6}  ",  ba3[i]);  

  
    }  
}
    
   
  
   



Output

Original contents of ba:
False  False  False  False  False  False  False  False  Result of ba XOR ba2:
False  False  True   True   True   True   False  True


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» BitArray