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 trialJacob Clinton
4,531 PointsThink about how to properly declare a variable and variable scope, then fix the following code so that it compiles.
I'm trying to get the code to run but no matter what I try I get an error can someone tell me the answer the code just throws errors that make no sense and every time I fix one error 2 more pop up
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
string output = null;
static void Main()
{
string input = Console.ReadLine();
if (input == "quit")
{
output = "Goodbye.";
}
else
{
string output = "You entered " + input + ".";
}
Console.WriteLine(output);
}
}
}
1 Answer
Steven Parker
231,210 PointsYou're very close, I see only two issues left:
- move the initialization of "output" down to put it insde the main method
- in the final else, change the initialization to an ordinary assignment
Jacob Clinton
4,531 PointsJacob Clinton
4,531 PointsThank you so much omg that task would have taken forever otherwise.