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

C# final

I am getting the message: System.ArgumentNullException. Can someone please help me debug this so I can move on. I have been working on this assignment for too long and am ready to quit.

Program.cs
using System;

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

                if (count <= 0)
                {
                    Console.WriteLine("You must enter a positive number.");
                    continue;
                }
                while (count > 0)
                {
                    Console.WriteLine("Yay!");
                    count--;
                }
            }
        }
    }
}
Jon Wood
Jon Wood
9,884 Points

What input are you giving it when you get that error?

1 Answer

Steven Parker
Steven Parker
231,269 Points

You have an outer loop that prevents the program from ending.

A program built according to the instructions will prompt and accept input one time, and based on the input it will either print "Yay!"s or an error mesage. Either way, it should end. With the extra loop it never ends.