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

Write code to print “C# Rocks!” to the console if language equals “C#”. Don't what to write here, help me!

I understand what loops do and if/else, but somehow I don't know what to code here.

CodeChallenge.cs
string language = Console.ReadLine();

2 Answers

It works. I was trying to put a ; after the if line and all I had to do was remove it and it worked.

andren
andren
28,558 Points

If you understand how if/else statements works then you might just be overthinking this challenge, because the solution is quite simple, all the challenge is asking you to do is check if the language variable is equal to "C#" and then print out "C# Rocks!" if it is, like this:

if (language == "C#") {
    System.Console.WriteLine("C# Rocks!");
}

If tried this but somehow it still doesnt work.. Maybe i am missing something. Could it be that I have create a variable named language first or a boolean??