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

Stuck. Please help.

I have added continue; to loop around, but error message says, "No enclosing loop out of which to break to or continue".

Program.cs
using System;

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

            if(entry<=0) {
                Console.WriteLine( entry + "You must enter a whole number.");
                continue;
            }

            for(var i = 0; i<entry; i++) {
                Console.WriteLine("Yay!");
            }

        }
    }
}

Thank you Rohit.

2 Answers

What for? You're not looping anything, you're simply checking whether the input of the user is less than or greater than 0. If you remove the "continue;" it should pass the challenge just fine

Thank you.

You could also place the following lines into a while loop:

Console.Write("Enter the number of times to print \"Yay!\": "); var entry = int.Parse(Console.ReadLine());

        if(entry<=0) {
            Console.WriteLine( entry + "You must enter a whole number.");
            continue;
        }