Set value in BitArray by indexer : BitArray « Collections « Visual C++ .NET






Set value in BitArray by indexer

 

#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()
{
    BitArray ^barray1 = gcnew BitArray( 8, true );
    Print(barray1, "BitArray( 8, true );");
    barray1[1] = false;
    barray1->Not();
    Print(barray1, "Modified bit 1&4 then Not");

}

   
  








Related examples in the same category

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