C# BitArray SetAll

Description

BitArray SetAll sets all bits in the BitArray to the specified value.

Syntax

BitArray.SetAll has the following syntax.


public void SetAll(
  bool value
)

Parameters

BitArray.SetAll has the following parameters.

  • value - The Boolean value to assign to all bits.

Returns

BitArray.SetAll method returns

Example

The following code example shows how to set and get specific elements in a BitArray.


//from  w  ww  .  java2 s.  c  o  m
using System;
using System.Collections;
public class SamplesBitArray  {

   public static void Main()  {
      BitArray myBA = new BitArray( 5 );
      PrintIndexAndValues( myBA );
      myBA.SetAll( true );
      PrintIndexAndValues( myBA );
   }
   public static void PrintIndexAndValues( IEnumerable myCol )  {
      foreach ( Object obj in myCol ) {
         Console.WriteLine(obj );
      }
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack