Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   help with c# curly brackets please (http://www.go4expert.com/forums/help-c-sharp-curly-brackets-t22030/)

 tayler2005 7May2010 14:30

help with c# curly brackets please

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";

 neo_vi 13May2010 21:00

Re: help with c# curly brackets please

If u feel difficult to close the correct curly brace, u can try this editor "Notepad++"

 LynxSI 24May2010 03:27

Re: help with c# curly brackets please

Quote:
 Originally Posted by tayler2005 (Post 67864) 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

 All times are GMT +5.5. The time now is 08:57.