Creating BitArray from array : BitArray « Collections « Visual C++ .NET






Creating BitArray from array

 

#include "stdafx.h"
using namespace System;
using namespace System::Collections;

void Print( BitArray ^barray, String ^desc)
{
    Console::WriteLine(desc);

    int i = 0;
    for each( bool^ val in barray )
    {
        Console::Write("{0} ", val);

        if (++i > 7)
        {
            Console::WriteLine();
            i = 0;
        }
    }
    Console::WriteLine();
}

void main()
{
    array<unsigned char>^ chars = gcnew array<unsigned char> { 0x55, 0xAA };
    BitArray ^barray3 = gcnew BitArray( chars );
    Print(barray3, "BitArray(0x55, 0xAA);");

    Console::WriteLine("Item[0]={0}", barray3[0]);
    Console::WriteLine("Item[8]={0}", barray3[8]);
}

   
  








Related examples in the same category

1.Creating BitArray
2.Set value in BitArray by indexer
3.Not on value in BitArray
4.And operation for two BitArray
5.Set all value in BitArray to true
6.Or operation between two BitArray
7.Xor operation between two BitArray