1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help with c# curly brackets please

Discussion in 'C#' started by tayler2005, May 7, 2010.

  1. tayler2005

    tayler2005 New Member

    Joined:
    May 7, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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";
     
  2. neo_vi

    neo_vi Member

    Joined:
    Feb 1, 2008
    Messages:
    722
    Likes Received:
    15
    Trophy Points:
    18
    Occupation:
    Software engineer
    Location:
    Earth
    Home Page:
    If u feel difficult to close the correct curly brace, u can try this editor "Notepad++"
     
  3. LynxSI

    LynxSI New Member

    Joined:
    May 23, 2010
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Developer
    Location:
    Vancouver, BC, Canada
    Home Page:
    }
    } //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
     

Share This Page