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

Gergo Bano
PLUS
Gergo Bano
Courses Plus Student 709 Points

What does “Unexpected symbol: ‘end-of-file’ “ mean?

I don’t quite understand the nature of the problem in this case. I’m already having trouble understanding the problem but I got to the point where my only error is this unexpected symbol, so I’d really appreciate it if you could help me.

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {            
            input = Console.ReadLine();
            try
            {
                int input = int.Parse(output);

                if (input == "quit")
                {
                string output = "Goodbye.";
                continue;
                }
                else
                {
                string output = "You entered " + input + ".";
                }
            }

            catch(FormatException)
            {


    }
}

1 Answer

Steven Parker
Steven Parker
229,744 Points

Both your "catch" block and the "Main" method are missing the closing brace to make them complete. The compiler is still looking for those when it encounters the end of the file. That's what the message means.

But you still have some scope issues to fix. And the instructions say, "Be sure to not change the intent or intended behavior of the code.". So your changes should only be minor ones necessary to fix the scope issues.

You won't want to make any major changes to the program operation such as adding "try...catch" features.