Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!!