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 trialIbrahim Buggati
266 PointsBummer! i have an error
I do not understand this! can please someone give me the answer because i have already asked this question 2 times..
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
string input = Console.ReadLine();
string output = Console.WriteLine();
if (input == "quit")
{
output = "Goodbye.";
}
else
{
output = "You entered " + input + ".";
}
Console.WriteLine(output);
}
}
}
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! The problem lies in your declaration of the output
variable. The Console.ReadLine()
returns a string from what the user inputs. But the Console.WriteLine()
returns nothing. Remember, it's simply for printing something back to the user. The compiler can't handle this because it's returning type void
back and trying to assign that to a variable that's supposed to hold a string.
You have this:
string output = Console.WriteLine();
But that should be:
string output;
This line declares a string named output
. Later on, we'll change the value of that variable based on what the input
value is, and that part is all correct.
Hope this helps!
[MOD: added c# formatting -cf]
Ibrahim Buggati
266 PointsThanks guys!
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsThough the challenge instructions say Declare the output variable just before the if statement and assign it to an empty string (i.e. ""), both the following are acceptable answers: