Set the bit at a specific position in the BitArray to the specified value in CSharp
Description
The following code shows how to set the bit at a specific position in the BitArray to the specified value.
Example
using System;//ww w. j av a2 s . co m
using System.Collections;
public class SamplesBitArray {
public static void Main() {
BitArray myBA = new BitArray( 5 );
myBA.Set( myBA.Count - 1, false );
PrintIndexAndValues( myBA );
}
public static void PrintIndexAndValues( IEnumerable myCol ) {
foreach ( Object obj in myCol ) {
Console.WriteLine(obj );
}
}
}
The code above generates the following result.