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

ali raafat
ali raafat
444 Points

can i get help in if/else

i need someone to check my work and tell me my mistake

CodeChallenge.cs
string language = Console.ReadLine();
bool language = true;
if (language == true)
{
    "C# Rocks!";
}

1 Answer

Steven Parker
Steven Parker
231,248 Points

:point_right: Your code attempts to declare language twice, and as different types.

Since the provided code already establishes the variable language as a string, you won't want to redeclare it as a bool. So you can remove line 2 completely.

Then the challenge says to print “C# Rocks!” to the console if language equals “C#”. So instead of comparing the variable language with true, you should compare it to the string "C#".

FInally, to print a string you need to pass that string as an argument to an output function, such as System.Console.WriteLine().

ali raafat
ali raafat
444 Points

their is a mistake

ali raafat
ali raafat
444 Points

how can i add Console.WriteLine