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

Compiler is saying that "while" is unexpected... not sure why

won't compile

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {
            Console.Write("Enter the number of times to print \"Yay!\": ");

            var entry = Console.ReadLine();
            var target = int.Parse(entry);
            var counter = 0

            while (counter < target) {
                counter += 1;
                Console.WriteLine("Yay!");
        }
    }
}

2 Answers

Hi John!

I think you might be missing a closing bracket there.

Good luck!

Also missing a semi-colon after "var counter = 0"

I had trouble with this too and I found that every single person on the forums who had solved it was using a 'for' statement, not a 'while' loop.

for(int counter = 0; counter < target; ++counter) {
                    Console.WriteLine("Yay!")
}