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

What I am missing here?

what I am missing in this code?

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

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

3 Answers

Keli'i Martin
Keli'i Martin
8,227 Points

You need to take language + out of the quotes. Right now, your code would output language + is not C#. Your code should look like this:

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

Hope this helps!

Rune Andreas Nielsen
Rune Andreas Nielsen
5,354 Points

Hi Yashoda.

In your code all of your string is with ".

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

You need to seperate the variable, "language" and the string you write out yourself.

So it looks like this

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

Here is full code.

string language = Console.ReadLine();

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

Thank you