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 trialMichael Thompson
7,427 PointsI have no idea what to do here
I'm lost completely
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);
}
}
}
1 Answer
Arturo Ortiz
1,502 PointsHello Michael. In this exercise you have to solve 2 problem.
The varaiable "input" is not being declare. Is already initialize but it wont compile if it doesnt have a type to declare it. So you must declare it of type "string" since you are getting input from the user. Answer: string input = Console.ReadLine();
The variable "output" is being declared and initialized 2 times in different scopes. The problem with this is that the variable "output" will only be visible in the "if" and "else" scope and after that it will be destroyed and you would not be able to print the value of the "output" variable at the end of the exercise. In order to correct this you need to declare the variable in the "main" scope so it can be accessible to all the other scopes within "main" . Answer: string output;