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

Michael Foster
Michael Foster
2,602 Points

"Bummer! Try again!"

This code challenge needs improvement.

The test automatically enters in "bogus" instead of "C#" and then quits when no loop is used(Despite correctly displaying the configured error message!). The challenge mentions nothing on how it expects to handle incorrect user input, then fails.

So I used a loop as is presumably intended. Now I just get the error "Bummer! Try again!" with no additional details. What gives?

CodeChallenge.cs
Console.WriteLine("Which language is the best?");
bool keepGoing = true;
while(keepGoing)
{
    string language = Console.ReadLine();
    if (language == "C#")
    {
        keepGoing = true;                      
    }
    else
    {
        Console.WriteLine("That's not what we want to hear! Try again!");
    }
}
Console.WriteLine("C# Rocks!");

1 Answer

Steven Parker
Steven Parker
211,076 Points

No, this challenge does not need (or accept) a loop.

And you don't need to print anything if the input is something other than "C#".

Just keep things simple, do only what the challenge asks and nothing else and you should pass easily.