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 trialRyan Colmon
Courses Plus Student 13,803 PointsChallenge Task 2 of 3 - Input Validation Help
Not sure where to go next with this one. Nothing I put in "Try" resolves the Format Exception errors. It sucks because I blew through step one.
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.Write("Enter the number of times to print \"Yay!\": ");
var entry = Console.ReadLine();
var yayCount = int.Parse(entry);
int loopCount = 0;
while (true)
{
//Prints "Yay!" to the screen the number of times entered
Console.WriteLine("Yay!");
//Keep track of how many times the loop has run
loopCount += 1;
if (loopCount == yayCount)
{
break;
}
try
{
}
catch(FormatException)
{
Console.WriteLine("You must enter a whole number.");
continue;
}
}
}
}
}
1 Answer
Ryan Colmon
Courses Plus Student 13,803 PointsNever mind folks, after looking through the Community board for a bit, I figured it out. Found out what I needed to move/input into "Try".