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 trialMytch Hagan
1,876 PointsIt's not working.
I tried to do as the video says and indent below the input variable, but it still says it couldn't be compiled.
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();
}
}
}
2 Answers
Taras Metelskii
4,167 PointsCause you didn't define type of input variable, use string or var to declare like this string input = Console.ReadLine() and code will compile.
Taras Metelskii
4,167 PointsSo you have multiple declaration of output, string output need to be declared before if else statement. And in Console.WriteLine() you need to pass output variable as an argument.
Mytch Hagan
1,876 PointsMytch Hagan
1,876 PointsIt's still didn't work.