You should go recursive (please note
2^100
is huge, so you need to be patient while waiting for the program to complete :-) ), e.g.
static void bits(int[] ab, int depth, int maxdept)
{
if (depth < maxdept)
{
ab[depth] = 0;
bits(ab, depth + 1, maxdept);
ab[depth] = 1;
bits(ab, depth + 1, maxdept);
}
else
{
foreach (int i in ab)
{
Console.Write(i);
}
Console.WriteLine();
}
}
public static void Main()
{
int[] ab;
ab = new int[100];
bits(ab, 0, 100);
}