Displays the properties and values of the BitArrays
using System; using System.Collections; public class SamplesBitArray { public static void Main() { // Creates and initializes several BitArrays. BitArray myBA1 = new BitArray( 5 ); BitArray myBA2 = new BitArray( 5, false ); byte[] myBytes = new byte[5] { 1, 2, 3, 4, 5 }; BitArray myBA3 = new BitArray( myBytes ); bool[] myBools = new bool[5] { true, false, true, true, false }; BitArray myBA4 = new BitArray( myBools ); int[] myInts = new int[5] { 6, 7, 8, 9, 10 }; BitArray myBA5 = new BitArray( myInts ); Console.WriteLine( "myBA1" ); Console.WriteLine( " Count: {0}", myBA1.Count ); Console.WriteLine( " Length: {0}", myBA1.Length ); Console.WriteLine( " Values:" ); PrintValues( myBA1, 8 ); } public static void PrintValues( IEnumerable myList, int myWidth ) { int i = myWidth; foreach ( Object obj in myList ) { if ( i <= 0 ) { i = myWidth; Console.WriteLine(); } i--; Console.Write( "{0,8}", obj ); } } }