C# C# Basics (Retired) Perform if / else

Tojo Alex
PRO
Tojo Alex
Pro 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
177,523 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
177,523 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.