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 trialali raafat
444 Pointscan i get help in if/else
i need someone to check my work and tell me my mistake
string language = Console.ReadLine();
bool language = true;
if (language == true)
{
"C# Rocks!";
}
1 Answer
Steven Parker
231,248 PointsYour code attempts to declare language twice, and as different types.
Since the provided code already establishes the variable language as a string, you won't want to redeclare it as a bool. So you can remove line 2 completely.
Then the challenge says to print “C# Rocks!” to the console if language equals “C#”. So instead of comparing the variable language with true, you should compare it to the string "C#".
FInally, to print a string you need to pass that string as an argument to an output function, such as System.Console.WriteLine().
ali raafat
444 Pointsali raafat
444 Pointstheir is a mistake
ali raafat
444 Pointsali raafat
444 Pointshow can i add Console.WriteLine