none
error CS1513 'curly bracket (}) expected with c# RRS feed

  • Question

  • namespace WindowsFormsApp1
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }
            public int player = 2; // even= X turn; odd= O turn;
            public int turnes = 0; //counting turns;
            //counting wins for both players and draws;
            public int s1 = 0;
            public int s2 = 0;
            public int sd = 0;
       
            private void Form2_Load(object sender, EventArgs e)
            {
            }
            private void buttonClick(object sender, EventArgs e)
            {
                Button button = (Button)sender;
                if(player%2==0)
                {
                    button.Text = "X";
                    player++;
                    turnes++;
                }
                else
                {
                    button.Text = "O";
                    player++;
                    turnes++;
                }
    Friday, March 1, 2019 11:17 PM

All replies

  • You need to add } to the end of the code to close out the form class and one for the last if statement.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Saturday, March 2, 2019 1:01 AM
    Moderator
  • Actually, you're missing 3 closing braces, not two:

    namespace WindowsFormsApp1
     {
         public partial class Form2 : Form
         {
             public Form2()
             {
                 InitializeComponent();
             }
    
            public int player = 2; // even= X turn; odd= O turn;
             public int turnes = 0; //counting turns;
             //counting wins for both players and draws;
             public int s1 = 0;
             public int s2 = 0;
             public int sd = 0;
    
    
        
             private void Form2_Load(object sender, EventArgs e)
             {
    
            }
    
            private void buttonClick(object sender, EventArgs e)
             {
                 Button button = (Button)sender;
                 if(player%2==0)
                 {
                     button.Text = "X";
                     player++;
                     turnes++;
                 }
                 else
                 {
                     button.Text = "O";
                     player++;
                     turnes++;
                 }
             } // missing
         } // missing
     } // missing


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, March 3, 2019 2:45 AM
    Moderator
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.
    Best Regards,

    Jack

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, March 4, 2019 6:21 AM
    Moderator