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


Im stuck, anyone help? :)

using System;

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


1 Answer

Steven Parker
Steven Parker
229,921 Points

First, you want the number of times to repeat as int, but Console.ReadLine() returns a string. So you need a way to convert the type, such as this:

            int number = int.Parse(Console.ReadLine());

Then, you need to control how many times you loop using that number. There are a few ways to do this, but one simple one is this:

            while(number-- > 0) 

Then finally, inside the loop, you need to write out "Yay!":


If you have trouble with the remaining steps of the challenge, you might want to review some of the videos.