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

Tojo Alex
PLUS
Tojo Alex
Courses Plus Student 13,331 Points

I don't know what i did wrong in the code challenge

This is the error that comes everytime: I entered bogus i expected bogus is not C# instead i got cheese is not C#

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

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

if (language != "C#"){

System.Console.WriteLine("Cheese is not C#");

}



}

2 Answers

Steven Parker
Steven Parker
231,210 Points

The word "Cheese" was just an example, the code needs to show what was actually input to the "language" variable. The instructions give you the argument to use :point_right: language + " is not C#."

Also, you don't need to perform another test, since the "else" code will only run if the language was not "C#".

Yu-Yang Hsiao
Yu-Yang Hsiao
6,295 Points

Hi~Maybe you can try the following codes.

string language = Console.ReadLine();
if (language == "C#")
{
   System.Console.WriteLine("{0} Rocks!",language);
}
else
{
   System.Console.WriteLine("{0} is not C#", language);            
}
Steven Parker
Steven Parker
231,210 Points

That will work, but you're getting ahead of the course. At this point, the concept of placeholder substitution hasn't yet been introduced and simple concatenation is expected.