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

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
210,475 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
210,475 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.