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 trialKabir Gandhi
2,107 PointsNot sure how to make this compile
Need to make this compile, but there is an error related to variable scope. Where can I move the declaration of input?
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
Jennifer Nordell
Treehouse TeacherHi there! Well, let's start with the first problem you're having: the declaration of the input
variable. There is something incorrect about that declaration. There's no data type.
Once you fix that, you'll see that there are other errors regarding the output
variable. Might I suggest changing the name of that variable to something else and making a declaration of it where your input
is but set to an empty string?
I hope these hints will help, but let me know if you're still stuck!
Adam Bader
4,811 PointsAdam Bader
4,811 PointsIt took me ONE HOUR to figure this out!!!! Thanks :) haha
Caio Viana
2,889 PointsCaio Viana
2,889 PointsI was stuck at this, but I did what you said about the input type for the output, I just put the
Console.WriteLine(output);
inside of the if/else statementsdidnt make a declaration of the variable...and it worked
am I wrong?