C# BitArray Xor
Description
BitArray Xor
performs the bitwise exclusive OR operation
on the elements in the current BitArray against the corresponding elements
in the specified BitArray.
Syntax
BitArray.Xor
has the following syntax.
public BitArray Xor(
BitArray value
)
Parameters
BitArray.Xor
has the following parameters.
value
- The BitArray with which to perform the bitwise exclusive OR operation.
Returns
BitArray.Xor
method returns The current instance containing the result of the bitwise exclusive OR 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 XOR to two BitArray instances.
using System;//from www .ja v a 2s . c o m
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.Xor( myBA2 ) );
}
public static void PrintValues( IEnumerable myList ) {
foreach ( Object obj in myList ) {
Console.WriteLine(obj );
}
}
}
The code above generates the following result.