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

Marwa Almoqbali
Marwa Almoqbali
639 Points

if else cant accepts the string variable in else!

I understand the program but when I go to console.writeline in else I want to declare the output of the language variable how?

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

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

1 Answer

Dale Severude
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,279 Points

Hi Marwa,

The language variable needs to be separated from the string with a plus sign.

Console.WriteLine(language + " is not C#");
Marwa Almoqbali
Marwa Almoqbali
639 Points

yes, I already tried this one but nothing happens! finally, I got it it was from the space after the double quotes. thank you.