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 trialJoe Nguyen
25,189 PointsChallenge 1 out of 1: What am I doing wrong?
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
string input = Console.ReadLine();
string output =
if (input == "quit")
{
output = "Goodbye.";
}
else
{
output = "You entered " + input + ".";
}
Console.WriteLine(output);
}
}
}
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
string input = Console.ReadLine();
string output =
if (input == "quit")
{
output = "Goodbye.";
}
else
{
output = "You entered " + input + ".";
}
Console.WriteLine(output);
}
}
}
2 Answers
Dave Harker
Courses Plus Student 15,510 PointsHi Joe,
The challenge states "Declare the output variable just before the if statement and assign it to an empty string (i.e. "")."
While you have added the output variable before the if, you've not assigned it the empty string, or terminated the line.
You have:
string output =
Needs to be:
string output = "";
Easy to miss, but you're on track now :) Keep going!
Dave.
Steven Parker
231,248 PointsYou're really close, it looks like you just have a typo.
On the line where "output" is declared, there's an equal sign ("=") at the end instead of a semicolon (";"):
string output; // fixed
The instructions say: and assign it to an empty string (i.e. ""), but that's not really necessary either for correct syntax or for passing the challenge.