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

Don't understand

I don't understand what to do because everything should work

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {            
            input = Console.ReadLine();

            if (input == "quit")
            {
                input = Console.ReadLine();
                string output = "Goodbye.";
            }
            else
            {
                string output = "You entered " + input + ".";


            Console.WriteLine(output);
            }

            }
    }
}

Ok so you're missing a few things here.

First thing is to check you have the brackets placed correctly and that they each have a closing bracket - take a look at the else statement.

Next, make sure you have declared your variables correctly - take a look at the input variable.

Finally, make sure that your code is doing what you want it to do. Ask yourself if Console.ReadLine() within the if(input == "quit") statement is correct.

Remember, the exercise only asked you to correct the code in order for it to compile. You can find the compile error by hitting "Check Work" and then "Preview".

1 Answer

Thank you very much