mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00] 1.0.5000.0 2.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Object System.Collections.ICollection System.ICloneable System.Runtime.InteropServices.ComVisible(true) The BItArray class implements a collection of Boolean values. There are several different constructors for initializing a new BitArray object. The implements an array of Boolean values as a collection. A BitArray can be resized by setting the property.
- Constructor
  A array.
  Constructs and initializes a new instance of the class where the inital values are set by the array.

  The size of the new BItArray will be the same as the Length of the Boolean array.

  using System; using System.Collections;

  public class BitArrayFromBoolArray { public static void Main () { BitArray bitArray = new BitArray (new bool [] {true, true, false, false, true}); Console.WriteLine ("bitArray.Count: {0}", bitArray.Count); for (int i = 0; i < bitArray.Count; i++) Console.WriteLine ("bitArray [{0}]: {1}", i, bitArray [i]); } }

  Compiling and running the above example generates the following output:

  bitArray.Count: 5

  bitArray [0]: True

  bitArray [1]: True

  bitArray [2]: False

  bitArray [3]: False

  bitArray [4]: True

  1.0.5000.0
  2.0.0.0
- Constructor
  An Array of Bytes.
  Constructs and initializes a new instance of the class where the inital values are set by the array.

  When using this constructor the new instance will allows have a Count that is 8 (i.e. the length of 1 Byte) times the length of the Byte array.

  using System; using System.Collections;

  public class BitArrayFromByteArray { public static void Main () { BitArray bitArray = new BitArray (new byte [] {byte.Parse ("25")}); Console.WriteLine ("bitArray.Count: {0}", bitArray.Count); for (int i = 0; i < bitArray.Count; i++) Console.WriteLine ("bitArray [{0}]: {1}", i, bitArray [i]); } }

  Compiling and running the above example generates the following output:

  bitArray.Count: 8

  bitArray [0]: True

  bitArray [1]: False

  bitArray [2]: False

  bitArray [3]: True

  bitArray [4]: True

  bitArray [5]: False

  bitArray [6]: False

  bitArray [7]: False

  1.0.5000.0
  2.0.0.0
- Constructor
  The BItArray to copy.

  Constructs and initializes a new instance of the class from an existing .

  using System; using System.Collections;

  public class BitArrayFromBitArray { public static void Main () { BitArray bitArray = new BitArray (new bool [] {true, true, false, false, true}); BitArray newBitArray = new BitArray (bitArray); Console.WriteLine ("bitArray.Count: {0}", bitArray.Count); for (int i = 0; i < bitArray.Count; i++) { Console.Write ("bitArray [{0}]: {1}", i, bitArray [i]); Console.WriteLine ("\tnewBitArray [{0}]: {1}", i, newBitArray [i]); } } }

  Compiling and running the above example generates the following output:

  bitArray.Count: 5

  bitArray [0]: True newBitArray [0]: True

  bitArray [1]: True newBitArray [1]: True

  bitArray [2]: False newBitArray [2]: False

  bitArray [3]: False newBitArray [3]: False

  bitArray [4]: True newBitArray [4]: True

  1.0.5000.0
  2.0.0.0
- Constructor
  The Length (Count) of the new BItArray.
  Constructs and initializes a new instance of the class with the specified Count and where the inital values are all set to false.

  The initial value of all Bits is false.

  using System; using System.Collections;

  public class BitArrayFromInt { public static void Main () { BitArray bitArray = new BitArray (7); Console.WriteLine ("bitArray.Count: {0}", bitArray.Count); for (int i = 0; i < bitArray.Count; i++) Console.WriteLine ("bitArray [{0}]: {1}", i, bitArray [i]); } }

  Compiling and running the above example generates the following output:

  bitArray.Count: 7

  bitArray [0]: False

  bitArray [1]: False

  bitArray [2]: False

  bitArray [3]: False

  bitArray [4]: False

  bitArray [5]: False

  bitArray [6]: False

  1.0.5000.0
  2.0.0.0
- Constructor
  To be added: an object of type 'int []'

  Constructs and initializes a instance of the class from an array of ints. The first value in the int array sets the leaset significant bits of the bit array.

  The int at index 0 of the int array sets the least significant bits of the . The bits of the are set using the two's complement value of the integers.

  using System; using System.Collections;

  public class BitArrayFromInt { public static void Main () { BitArray bitArray = new BitArray (new int [] {-1, 0}); Console.WriteLine ("bitArray.Count: {0}", bitArray.Count); for (int i = 0; i < bitArray.Count; i += 8) { Console.WriteLine ("bitArray [{0}]: {1}", i, bitArray [i]); Console.WriteLine ("bitArray [{0}]: {1}", i + 7, bitArray [i + 7]); } } }

  Compiling and running the above example generates the following output:

  bitArray.Count: 64

  bitArray [0]: True

  bitArray [7]: True

  bitArray [8]: True

  bitArray [15]: True

  bitArray [16]: True

  bitArray [23]: True

  bitArray [24]: True

  bitArray [31]: True

  bitArray [32]: False

  bitArray [39]: False

  bitArray [40]: False

  bitArray [47]: False

  bitArray [48]: False

  bitArray [55]: False

  bitArray [56]: False

  bitArray [63]: False

  1.0.5000.0
  2.0.0.0
- Constructor
  The Length (Count) of the new BItArray.
  The initial value of all Bits.
  Constructs and initializes a new instance of the class with the specified Count and all values initialized to either true or false.
  using System; using System.Collections;

  public class BitArrayFromIntWithDefault { public static void Main () { BitArray bitArray = new BitArray (7, true); Console.WriteLine ("bitArray.Count: {0}", bitArray.Count); for (int i = 0; i < bitArray.Count; i++) Console.WriteLine ("bitArray [{0}]: {1}", i, bitArray [i]); } }

  Compiling and running the above example generates the following output:

  bitArray.Count: 7

  bitArray [0]: True

  bitArray [1]: True

  bitArray [2]: True

  bitArray [3]: True

  bitArray [4]: True

  bitArray [5]: True

  bitArray [6]: True

  1.0.5000.0
  2.0.0.0
- Method
  System.Collections.BitArray `` The to And with the current instance. Performs a bitwise And on two instances. A BitAray whose bit values are the bitwise And of the BItArray instance and the argument BitArray.

  The result of the And operation overwrites the original instance.

  The two BitArrays must be the same length. If they are not an will be thrown.

  `using System; using System.Collections; using System.Text; public class BitArrayAnd { public static void Main () { BitArray leftOperand = new BitArray (new byte [] {byte.Parse ("9")}); BitArray rightOperand = new BitArray (new byte [] {byte.Parse ("10")}); BitArrayOut.PrintBitArray (leftOperand, " And "); BitArrayOut.PrintBitArray (rightOperand, " = "); leftOperand.And (rightOperand); BitArrayOut.PrintBitArray (leftOperand, "\n"); } } public static class BitArrayOut { internal static void PrintBitArray (BitArray bitArray) { Console.Write (BitArrayToString (bitArray)); } internal static void PrintBitArray (BitArray bitArray, string symbol) { PrintBitArray (bitArray); Console.Write (symbol); } private static string BitArrayToString (BitArray bitArray) { StringBuilder stringBuilder = new StringBuilder (); for (int i = bitArray.Count - 1; i > -1; i--) { char digit = bitArray[i] ? '1' : '0'; stringBuilder.Append (digit); } return stringBuilder.ToString(); } }`

  Compiling and running the above example generates the following output:

  00001001 And 00001010 = 00001000

  1.0.5000.0
  2.0.0.0
- Method
  System.Object

  Returns a that is a copy of the current instance.

  A that is a copy of the current instance.

  To be added 1.0.5000.0 2.0.0.0
- Method
  System.Void `` `` The one-dimensional that is the destination of the elements copied from the current instance. The of this array is greater than or equal to the sum of and the of the current instance. A that specifies the first index of to which the elements of the current instance are copied. This value is greater than or equal to zero, and less than .Length.

  Copies the elements from the current instance to the specified , starting at the specified index of the array.

  To be added 1.0.5000.0 2.0.0.0
- Property
  System.Int32 Gets the number of elements contained in the current instance.

  A that specifies the number of elements contained in the current instance.

  This property is read-only.

  is the number of elements that are contained by the .

  The is equal to .

  This property is implemented to support the interface.

  1.0.5000.0
  2.0.0.0
- Method
  System.Boolean `` The index of the element to return. Get the specified element from the . Returns the value of the specified element. If the index is out of range a will be thrown. 1.0.5000.0 2.0.0.0
- Method
  System.Collections.IEnumerator

  Returns an for the current instance.

  An for the current instance.

  To be added 1.0.5000.0 2.0.0.0
- Property
  System.Boolean

  Gets a value indicating whether the current instance is read-only.

  The value of this property is always false.

  To be added 1.0.5000.0 2.0.0.0
- Property
  System.Boolean

  Gets a value indicating whether access to the current instance is synchronized (thread-safe).

  The value of this property is always false.

  To be added 1.0.5000.0 2.0.0.0
- Property
  System.Boolean `` A that specifies the zero-based index of the element in the current instance to get or set. This value must be greater than or equal to 0, and less than the of the current instance.

  Gets or sets the element at the specified index of the current instance.

  The element at the specified index of the current instance.

  To be added 1.0.5000.0 2.0.0.0
- Property
  System.Int32 Gets or Sets the number of elements contained in the current instance. Setting the Length causes the BitArray to be resized.

  A that specifies the number of elements contained in the current instance.

  is the number of elements that are contained by the .

  The is equal to .

  1.0.5000.0
  2.0.0.0
- Method
  System.Collections.BitArray Negates all of the bits in a . A BitAray whose bit values are the negation of the BItArray instance.

  The result of the Not operation overwrites the original instance.

  `using System; using System.Collections; using System.Text; public class BitArrayNot { public static void Main () { BitArray bitArray = new BitArray (new bool [] {true, false, false, true}); Console.Write ("bitArray: "); BitArrayOut.PrintBitArray (bitArray, "\n"); Console.Write ("bitArray.Not(): "); bitArray.Not (); BitArrayOut.PrintBitArray (bitArray, "\n"); } } public static class BitArrayOut { internal static void PrintBitArray (BitArray bitArray) { Console.Write (BitArrayToString (bitArray)); } internal static void PrintBitArray (BitArray bitArray, string symbol) { PrintBitArray (bitArray); Console.Write (symbol); } private static string BitArrayToString (BitArray bitArray) { StringBuilder stringBuilder = new StringBuilder (); for (int i = bitArray.Count - 1; i > -1; i--) { char digit = bitArray[i] ? '1' : '0'; stringBuilder.Append (digit); } return stringBuilder.ToString(); } }`

  Compiling and running the above example generates the following output:

  bitArray: 1001

  bitArray.Not(): 0110

  1.0.5000.0
  2.0.0.0
- Method
  System.Collections.BitArray `` The to Or with the current instance. Performs a bitwise Or of two instances. A BitAray whose bit values are the bitwise Or of the BItArray instance and the argument BitArray.

  The result of the Or operation overwrites the original instance.

  The two BitArrays must be the same length. If they are not an will be thrown.

  `using System; using System.Collections; public class BitArrayOr { public static void Main () { BitArray leftOperand = new BitArray (new bool [] {true, false, false, true}); BitArray rightOperand = new BitArray (new bool [] {true, false, true, false}); BitArrayOut.PrintBitArray (leftOperand, " Or "); BitArrayOut.PrintBitArray (rightOperand, " = "); leftOperand.Or(rightOperand); BitArrayOut.PrintBitArray (leftOperand, "\n"); } } public static class BitArrayOut { internal static void PrintBitArray (BitArray bitArray) { Console.Write (BitArrayToString (bitArray)); } internal static void PrintBitArray (BitArray bitArray, string symbol) { PrintBitArray (bitArray); Console.Write (symbol); } private static string BitArrayToString (BitArray bitArray) { StringBuilder stringBuilder = new StringBuilder (); for (int i = bitArray.Count - 1; i > -1; i--) { char digit = bitArray[i] ? '1' : '0'; stringBuilder.Append (digit); } return stringBuilder.ToString(); } }`

  Compiling and running the above example generates the following output:

  1001 Or 0101 = 1101

  1.0.5000.0
  2.0.0.0
- Method
  System.Void `` `` The index of the element to be set. The value to set the indexed element to. Sets the specified element of the to the value specified. If the index is out of range a will be thrown. 1.0.5000.0 2.0.0.0
- Method
  System.Void `` true or false, all elements of the will be set to this value. Sets all the elements of the to either true or false. To be added 1.0.5000.0 2.0.0.0
- Property
  System.Object

  Gets an object that can be used to synchronize access to the current instance.

  A that can be used to synchronize access to the current instance.

  An instance of the class should be synchronized using this property and not directly using the instance. Using this property ensures the correct operation of derived classes.

  1.0.5000.0
  2.0.0.0
- Method
  System.Collections.BitArray `` The to Xor with the current instance. Performs a bitwise Xor of two BitArray instances. A BitAray whose bit values are the bitwise Xor of the BItArray instance and the argument BitArray.

  The result of the Xor operation overwrites the original instance.

  The two BitArrays must be the same length. If they are not an will be thrown.

  `using System; using System.Collections; using System.Text; public class BitArrayXor { public static void Main () { BitArray leftOperand = new BitArray (new bool [] {true, false, false, true}); BitArray rightOperand = new BitArray (new bool [] {true, false, true, false}); BitArrayOut.PrintBitArray (leftOperand, " Xor "); BitArrayOut.PrintBitArray (rightOperand, " = "); leftOperand.Xor (rightOperand); BitArrayOut.PrintBitArray (leftOperand, "\n"); } } public static class BitArrayOut { internal static void PrintBitArray (BitArray bitArray) { Console.Write (BitArrayToString (bitArray)); } internal static void PrintBitArray (BitArray bitArray, string symbol) { PrintBitArray (bitArray); Console.Write (symbol); } private static string BitArrayToString (BitArray bitArray) { StringBuilder stringBuilder = new StringBuilder (); for (int i = bitArray.Count - 1; i > -1; i--) { char digit = bitArray[i] ? '1' : '0'; stringBuilder.Append (digit); } return stringBuilder.ToString(); } }`

  Compiling and running the above example generates the following output:

  1001 Xor 0101 = 1100

  1.0.5000.0
  2.0.0.0