for (int y = 0; y < GameBoard.GameBoardHeight; y++)
for (int x = 0; x < GameBoard.GameBoardWidth; x++)
{
if (GetSquare(x, y) == "Empty")
{
RandomPiece(x, y);
}
}
The first for loop has no braces, and the next line is not even a statement with a ;. It’s just a for loop.
Whats up with this?
Enclose the statements to be iterated over in curly braces. If only one statement should be included in the loop, the curly braces can be omitted.
Opening and closing braces for if, for, or while statements should always be used even if the statement’s body contains only a single statement.
Braces improve the uniformity and readability of code. More important, when inserting an additional statement into a body containing only a single statement, it is easy to forget to add braces because the indentation gives strong (but misleading) guidance to the structure.
NOTE : After the loop. Without curly braces, only the first statement immediately after the for loop statement will be in the loop.
see this for more info: http://www.dotnetperls.com/omit-curly-brackets