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.

ali raafat
444 Pointscan i get help in this if/else
i need someone to tell me my mistake.
string language = Console.ReadLine();
if(language == "C#")
{
System.Console.WriteLine("C# Rocks!");
}
else
{
language == "is not C#";
}
2 Answers

markmneimneh
14,132 PointsIf you need anything printed, you need to add a print statement. Something like this
System.Console.WriteLine("is not C#");
instead of
language = "is not C#";
or you can even do this ...
language = "is not C#";
System.Console.WriteLine(language);
I am just pointing you into the right direction. You choose.

markmneimneh
14,132 PointsHello
the problem is in the else statement. else is executed when the condition in the if statement is not met. Therefore, else is what you want the code to do when if is by passed
string language = Console.ReadLine();
if(language == "C#")
{
System.Console.WriteLine("C# Rocks!");
}
else
{
language == "is not C#";
}
try this instead(please note the = insted of ==)
string language = Console.ReadLine();
if(language == "C#")
{
System.Console.WriteLine("C# Rocks!");
}
else
{
language = "is not C#";
}
If this answers your question, please mark the question as answered.

ali raafat
444 Pointsnothing was printed out its not working
ali raafat
444 Pointsali raafat
444 Pointswhat is the difference
ali raafat
444 Pointsali raafat
444 Pointsits not working in tried both