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 Variable Scope

Kanwaldeep Sekhon
PLUS
Kanwaldeep Sekhon
Courses Plus Student 1,298 Points

warning CS0642: Possible mistaken empty statement

I'm not sure what else needs to be in the else clause for this code challenge. Any ideas? Anybody?

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {            
            string input = Console.ReadLine();

            if (input == "quit")
            {
                Console.WriteLine("Goodbye.");
            }
            else if ()
            {
                Console.WriteLine = "You entered " + input + ".";
            }

            Console.WriteLine(input);
        }
    }
}

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

You're pretty close but you're you have an empty if statement after the else, and no parentheses for the WriteLine call. The else should be used alone if there's no other condition you need to check.

            if (input == "quit")
            {
                Console.WriteLine("Goodbye.");
            }
            else
            {
                Console.WriteLine ("You entered " + input + ".");
            }
Kanwaldeep Sekhon
Kanwaldeep Sekhon
Courses Plus Student 1,298 Points

Oh, thank you. I was over-analyzing it thinking I needed to put something for the output too.