Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Basics (Retired) Perfect Variable Scope

the workspace is throwing exceptions that are not true. For example, "unexpected if symbol on line 9." No if on line 9.

workspace error. It will not let me continue.

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {            
            string input = Console.ReadLine();
            string output = " "
            if (input == "quit")
            {
                 output = "Goodbye.";
            }
            else
            {
                 output = "You entered " + input + ".";
            }

            Console.WriteLine(output);
        }
    }
}

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Yes, and no. Remember, this isn't a workspace and what you are getting back is very really a compiler error. With the exception of the line number, this is the same compiler error any C# compiler would give you. But you're very close here... you're literally one character off.

Program.cs(9,12): error CS1525: Unexpected symbol `if'

Now, the line numbers don't exactly match up, likely because of the way Treehouse imports your code on their end. Some of the first few lines might be negated by them. But the "Unexpected symbol 'if'" is very accurate.

:bulb: When you see "unexpected" it generally means that something above that line was not concluded correctly.

Such is the case here. In the previous line, you simply forgot a semicolon to end the statement. Putting a semicolon on the end of the line above the if causes your code to pass the challenge. Well done!

Hope this helps! :sparkles:

Oh wow. You're right. Thank you!!