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 trialAly Khedr
470 PointsI don't know what I did wrong. My code should see if the string Language is equal to "C#" and then write what C# rocks!
I sort of wrote everything in the title.
string language = Console.ReadLine();
if(language == "C#")
{
Console.Write("C# Rocks!")
}
1 Answer
Steven Parker
231,269 PointsYou're just missing a semicolon.
The line with the Write should end with a semicolon (";
").
When something goes wrong, many times you can get some information that will help fix it by hitting the Preview button. This is particularly true when it says your code "could not be compiled." In this case, the Preview showed the error message: "error CS1002: ; expected".
Aly Khedr
470 PointsAly Khedr
470 PointsI did what you said and added the semicolon and still nothing
Steven Parker
231,269 PointsSteven Parker
231,269 PointsMaybe you put it in the wrong place? Please show the code that you are entering now.
Aly Khedr
470 PointsAly Khedr
470 Pointsstring language = Console.ReadLine();
if(language == "C#"); { Console.Writeline("C# Rocks!"); }
Steven Parker
231,269 PointsSteven Parker
231,269 PointsAhh, you added two semicolons, one in the right place, and another in a wrong place.
There should not be a semicolon between the conditional expression of the if statement and the open brace of the code block.
Aly Khedr
470 PointsAly Khedr
470 PointsWrath of the semicolon. thank you.