Set all value in BitArray to true : BitArray « Collections « Visual C++ .NET






Set all value in BitArray to true

 

#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 );");

    BitArray ^barray2 = gcnew BitArray( 8, true );
    barray2->And(barray1);
    Print(barray2, "And with BitArray( 8, true )");
    
    barray2->SetAll(true);
    barray2->Or(barray1);
    Print(barray2, "Or with BitArray( 8, true )");
}

   
  








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.Or operation between two BitArray
6.Xor operation between two BitArray
7.Creating BitArray from array