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

Pratham Patel
Pratham Patel
4,976 Points

I don't understand this

Please help with this code challenge what do i need to do

Program.cs
using System;

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

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

            Console.WriteLine(output);
        }
    }
}

2 Answers

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

The point of this challenge is to teach you how to debug code. As such, I'm uncomfortable giving a straight out answer on this one. Your best bet is to do the check work immediately before changing anything. Click the preview button to view the error messages. But here's a clue :bulb: when you see that the name "something" does not exist in the current context it can mean a couple of things. It can mean that a variable name is misspelled, it's not in the correct scope, or it hasn't been properly declared.

Take another shot at it! Good luck :smiley:

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

The important thing to look for is variable scope.