Mega Code Archive

 
Categories / Visual C++ .NET / Collections
 

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]); }