Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Basics (Retired) Perform if

Henry Camacho
Henry Camacho
1,735 Points

problem with a challenge task

i have written out my code in the challenge task but for some reason it seems to be ignoring my if statement when bogus is entered. i am stumped and i cant move on in the lessons till it is fixed please help

string language = Console.ReadLine();
if (language == "C#");
    Console.WriteLine("C# Rocks!");

1 Answer

28,526 Points

The issue is the semicolon you have placed at the end of the if statement line:

if (language == "C#"); // <-- That semicolon does not belong there

By placing a semicolon there you tell C# that the if statement is done, so the next line gets treated as regular code, not code that is a part of the if statement.

If you remove the semicolon then your code will work fine.