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

mehmet odabas
mehmet odabas
2,120 Points

compiler error in if else statement

StudentsCode.cs(14,39): error CS1056: Unexpected character ?' StudentsCode.cs(14,40): error CS1525: Unexpected symbolis' StudentsCode.cs(14,48): error CS1644: Feature type pattern matching' cannot be used because it is not part of the C# 6.0 language specification StudentsCode.cs(14,49): error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line StudentsCode.cs(14,51): error CS1056: Unexpected character?' StudentsCode.cs(14,51): error CS1525: Unexpected symbol `)' Compilation failed: 6 error(s), 0 warnings

compiler gave that errors but i couldn't get where did i do sth wrong

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

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

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

It appears that the " " in your code is the Unexpected symbol, I wonder, are you using a non-US keyboard setting?

string language = Console.ReadLine();

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

This should work fine.

mehmet odabas
mehmet odabas
2,120 Points

i'm using TR(turkish) keyboard setting but in javascript lessons or c# lessons before this exam, there was not any problems. i only get a problem like that in this exam.

Andy Swinford
Andy Swinford
8,152 Points

definitely the weird quotation marks causing the issue.

stephen Capes
stephen Capes
1,002 Points

it doesn't it throws up "I entered "bogus" and "bogusis not C#." was printed out."