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 trial

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

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

1 Answer

andren
andren
28,558 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.