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

Unable to get code to compile

I can't figure out what I'm doing wrong.

using System;

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

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

Moderator Edit: Added Markdown to code snippet to render properly and readable in the Post.

2 Answers

Mojisola Sodunke
PLUS
Mojisola Sodunke
Courses Plus Student 2,034 Points

using System;

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

        if(input == "quit")                          # no space between if (input == "quit")
        {
             Console.WriteLine("Goodbye.");                 # don't put space between Console.WriteLine ("Goodbye");
        }
        else
        {
            Console.WriteLine( "You entered " + input + "."); 
        }
}

}

Try this

Carlos Fernando Gómez Carrero
Carlos Fernando Gómez Carrero
46,984 Points

I think you are just missing a closing } in the Main method:

static void Main()
        {