Ask coding questions

← Back to all posts
Whats wrong
JacobMcPherson1 (193)

I'm getting an error that says I have an unexpected identifier and I can't fix it. Can someone help? I'm pretty new to C# so don't judge me, please

Answered by MocaCDeveloper (560) [earned 5 cycles]
View Answer
MocaCDeveloper (560)

Line 8-19 should be as so:

    if (lol == '1') 
      Console.WriteLine ("How much time do you want to count to in seconds");
      int y = Convert.ToInt32(Console.ReadLine());
      int hehe;
      for (hehe = 0; hehe < y + 1; hehe++) 
        Console.WriteLine (hehe);
    } // you missed this.
    else if (lol == '2')

On line 18, you had the closing curly brace for the for loop, but you failed to put the closing curly brace for the if statement.