help with c# curly brackets please

tayler2005's Avatar, Join Date: May 2010
Newbie Member
Hi im writing a simple tic tac toe program, im pretty new to c# and am struggling with my curly brackets.

Ive got the code for my computer move function but am having problems putting the curly brackets in the right place for my loops. Ive now taken all the brackets out and am gonna start again.

Any help or suggestions would be appreciated
Thanks

This is my code:

int x = 0;
int y = 0;

for (x = 0; x < 2; x++)

for (y = 0; y < 2; y++)

if (matrix[x, y] == " ")
break;

if (matrix[x, y] == " ")
break;

if ((x * y) > 4)

done = "d";

else

matrix[x, y] = "o";
0
neo_vi's Avatar, Join Date: Feb 2008
Invasive contributor
If u feel difficult to close the correct curly brace, u can try this editor "Notepad++"
0
LynxSI's Avatar
Go4Expert Member
Quote:
Originally Posted by tayler2005 View Post
Hi im writing a simple tic tac toe program, im pretty new to c# and am struggling with my curly brackets.

Ive got the code for my computer move function but am having problems putting the curly brackets in the right place for my loops. Ive now taken all the brackets out and am gonna start again.

Any help or suggestions would be appreciated
Thanks

This is my code:

int x = 0;
int y = 0;

for (x = 0; x < 2; x++)
{
for (y = 0; y < 2; y++)
{
if (matrix[x, y] == " ")
break;

if (matrix[x, y] == " ")
break;

if ((x * y) > 4)
{
done = "d";
}
else
{
matrix[x, y] = "o";
}
} //End for(y) loop
} //End for(x) loop

I'm not sure what this code is supposed to do as I can't see the declaration of whole funciton/method and the variable/object 'done'. But I'll take a guess where your brackets should be above.

Also what are you using as a code editor? VisualStudio will highlight the matching curly brace when editing so that you can see which ending brace matches the current opening brace when you are going through your code. Try moving the cursor to an opening brace, it should turn bold as well as the matching closing brace.

- Ben