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 / else


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


Someone please explain me where is the mistake?


string language = Console.ReadLine();

if(language == "C#")
  System.Console.WriteLine("C# Rocks!");
Console.WriteLine(""+ language +"is not C#.");


2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! The problem lies in the string that you're printing in the else statement. You seem to understand that you need a space, but seem unsure how to do it. Right now, if I were to send in "Java", your code would print out:

Javais not C#.

But we would want it to print out:

Java is not C#.

Note the space between the value of language and the rest of the string. To do this, we can simply add an extra space in our string literal.

Console.WriteLine(language + " is not C#.");

This would print out the language we typed in with the appropriate spacing. Remember that when you print the value of a variable, no spacing is implied. If you want spacing, you have to explicitly put it somewhere.

Hope this helps! :sparkles:

Thanks a prompt reply! All clear