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

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