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 trialKirill Budnikov
537 PointsIs C# Code Challenge: Final broken or is it just me?
My code works perfectly when I compile and run it through Workspaces, but in the challenge all I get is: "Bummer! System.ArgumentNullException: Value cannot be null. Parameter name: String. See output for stack trace." I even tried to catch this absurd "null" exception. But then I get just "Bummer! Try again" without any details. Here's my code:
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
int yayTimes = 0;
while (true)
{
Console.Write("Enter the number of times to print \"Yay!\": ");
string entry = Console.ReadLine();
try
{
yayTimes = int.Parse(entry);
}
catch (FormatException)
{
Console.WriteLine("You must enter a whole number.");
continue;
}
break;
}
for (int i = 0; i < yayTimes; i++)
{
Console.Write("Yay! ");
}
}
}
}
1 Answer
Kirill Budnikov
537 PointsSooo.. my mistake was that I thought the program should ask for a valid entry again if it was invalid. As soon as I got it, I just replaced my "continue;" with another "break;". A ton of negative emotions just because I didn't understand the requirements. Well, I call it a lesson.
Dan Comperini
Courses Plus Student 2,215 PointsDan Comperini
Courses Plus Student 2,215 PointsI had the same issue. The requirements were not explained very well and the code does work.