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

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.

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.

28,504 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??