Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
211,076 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