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 Final

Kevin Khlom
Kevin Khlom
14,369 Points

Keep getting "unexpected symbol" with counter int in C# final.

I keep getting an error with the counter variable. The system errors out counter as an unexpected symbol. Can anybody tell me how I can get around this?

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {
            Console.Write("Enter the number of times to print \"Yay!\": ");
            int entry = Console.ReadLine();
            int yay = int.Parse(entry);
            var counter = 0;

            while (yay > counter)
            {
                Console.WriteLine("Yay!")
                counter += 1;

            }

        }
    }
}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! When you fix this part you'll find that you have some more errors. But the problem causing your current compilation error is a missing semicolon on this line:

Console.WriteLine("Yay!")

That should be:

Console.WriteLine("Yay!");

Hope this helps! :sparkles:

Kevin Khlom
Kevin Khlom
14,369 Points

That did help. Thank you so much for your response.