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) Perfect if / else if / else

Chris Hildebran
Chris Hildebran
700 Points

Why this error [StudentsCode.cs(15,5): error CS1525: Unexpected symbol `if']?Only a closing bracket on this line!

I keep going back and forth between code and results but dont see a coorelation.

CodeChallenge.cs
string input = Console.ReadLine();
int temperature = int.Parse(input);

if (temperature< 21)
{
System.Console.WriteLine("Too Cold!");
}

Else if (temperature == 21)
{
System.Console.WriteLine("Just Right.");
{

    Else if (temperature > 22)
{
System.Console.WriteLine("Too hot!");   
}

else
{
System.Console.WriteLine("asdf");
}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! In two places, you have miscapitalized "else" as "Else". Always assume in programming that everything is case-sensitive. Note how your very last else is orange meaning that it's a reserved word, while your two Else are white. It means that the compiler believes Else is an undefined variable. Correcting the capitalization should get you past that error.

Hope this helps! :sparkles:

edited for additional tip

:bulb: On a side note, whenever you see a compiler error and it says something like error on line 15 but you can't find anything wrong with line 15 at all, start looking upwards in your code. 99% of the time, it's something that's happening before that line that's incorrect.