C# BitArray And
Description
BitArray And
performs the bitwise AND operation on the
elements in the current BitArray against the corresponding elements in
the specified BitArray.
Syntax
BitArray.And
has the following syntax.
public BitArray And(
BitArray value
)
Parameters
BitArray.And
has the following parameters.
value
- The BitArray with which to perform the bitwise AND operation.
Returns
BitArray.And
method returns The current instance containing the result of the bitwise AND operation
on the elements in the current BitArray against the corresponding elements
in the specified BitArray.
Example
The following code example shows how to apply AND to two BitArray instances.
//from w w w . j a v a 2s .com
using System;
using System.Collections;
public class SamplesBitArray {
public static void Main() {
BitArray myBA1 = new BitArray( 4 );
BitArray myBA2 = new BitArray( 4 );
myBA1[0] = myBA1[1] = false;
myBA1[2] = myBA1[3] = true;
myBA2[0] = myBA2[2] = false;
myBA2[1] = myBA2[3] = true;
PrintValues( myBA1.And( myBA2 ) );
}
public static void PrintValues( IEnumerable myList) {
foreach ( Object obj in myList ) {
Console.WriteLine(obj );
}
}
}
The code above generates the following result.