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.

ali raafat
444 Pointscan i get help in variable scoop
i don't know why it keeps giving me an error about input
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
try
{
input = Console.ReadLine();
if (input == "quit")
{
string output = "Goodbye.";
}
else
{
string output = "You entered " + input + ".";
}
}
catch(Exception)
{
Console.WriteLine(output);
}
}
}
}
1 Answer

Steven Parker
215,972 Points
Variables need to be declared before they are used (or as they are initialized).
The error you see about input is because it has not been declared.
Once you fix that, you'll also need to check that variables are declared in the outermost scope in which they are used. Remember you can assign a variable many times, but you should only declare it once.
ali raafat
444 Pointsali raafat
444 Pointshow can i know and how to add one iam confused
Steven Parker
215,972 PointsSteven Parker
215,972 PointsBy "one" ... do you mean declaration?
A simple declaration:
variable_type variable_name; (example:
int jellies;
)A declaration with initialization:
variable_type variable_name = Initial_value; (example:
string food = "doughnut";
)