100 doors exercise code using C#
I have no idea what this does:

if (i == 3) {
    temp = temp1;
    temp1 = temp2;
    temp2 = temp;
}


Please don't say if (test == true) or if (test == false)

but just if (test) or if (!test)

and you can just say else instead else if (test == false)

But your code in overly complex anyway. How about just this:

    bool[] doors = new bool[101];
    for (int step = 1; step &lt;= 100; ++step) {
        for (int door = step; door &lt;= 100; door += step) {
            doors[door] = !doors[door];
        }
    }

    for (int door = 1; door &lt;= 100; ++door) {
        if (doors[door]) Console.WriteLine(door);
    }


You'll see that the output is all the square numbers: 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100