G
george r smith
All,
I have written the following code and it works but I am having a hard time
understanding the following call:
public static void PrintBitArray(IEnumerable aBitArray, int myWidth )
Here I am passing in a BitArray with a type of IEnumerable. Now I know that
IEnumerable is an interface and that BitArray implements the IEnumerable
interface. What I do not understand is why you use "(IEnumerable aBitArray"
in the call.
thanks
grs
====
in Main()
BitArray aBitArray = new BitArray(64);
PrintBitArray(aBitArray, 8);
.....
=====
public static void PrintBitArray(IEnumerable aBitArray, int myWidth )
{
IEnumerator myEnumerator = aBitArray.GetEnumerator();
int i = myWidth;
while (myEnumerator.MoveNext())
{
if ( i <= 0 )
{
i = myWidth;
Console.WriteLine();
}
i--;
Console.Write("\t{0}", myEnumerator.Current);
}
Console.WriteLine();
}
I have written the following code and it works but I am having a hard time
understanding the following call:
public static void PrintBitArray(IEnumerable aBitArray, int myWidth )
Here I am passing in a BitArray with a type of IEnumerable. Now I know that
IEnumerable is an interface and that BitArray implements the IEnumerable
interface. What I do not understand is why you use "(IEnumerable aBitArray"
in the call.
thanks
grs
====
in Main()
BitArray aBitArray = new BitArray(64);
PrintBitArray(aBitArray, 8);
.....
=====
public static void PrintBitArray(IEnumerable aBitArray, int myWidth )
{
IEnumerator myEnumerator = aBitArray.GetEnumerator();
int i = myWidth;
while (myEnumerator.MoveNext())
{
if ( i <= 0 )
{
i = myWidth;
Console.WriteLine();
}
i--;
Console.Write("\t{0}", myEnumerator.Current);
}
Console.WriteLine();
}