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!

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

C# Basics Final Challenge; Printing "Yay!"

Getting a compiler error that I don't understand here. Tells me that "Console" is unexpected? Something wrong with my variable scope? Any other pointers are welcome, too. Hopefully I'm not too far off track here.

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {   
            var counter = 0

            Console.Write("Enter the number of times to print \"Yay!\": ");

            var entry = Console.Readline();

            while(int.Parse(entry) >= counter)
            {                
                Console.Write("Yay!");
                ++ counter;
            }
        }
    }
}

Hey Adam,

You're missing a semi-colon brother...right after the 0.

1 Answer

Steven Parker
Steven Parker
225,730 Points

You're missing a semicolon.

The line that initializes counter is missing the semicolon at the end. That's why "Console" (on the following line) was unexpected.

Also, you wrote "Readline" (with a lower case "l") instead of "ReadLine" (with capital "L").

And you might need to adjust how you do your comparison to get the correct number of outputs.

Thanks so much! After posting I searched the forums a bit more and encountered others who'd made similar mistakes and found some code that worked. Then I compared my original and saw the gaffes. Muddled through the rest of the challenge with some more of the same trial and error. Really appreciate the feedback!