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 trialAlexander Gallardo
617 PointsI am having an issue with the try catch exception, and also It only accepts -- to INCREASE the times it prints. Help?
Please help me.
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.Write("Enter the number of times to print \"Yay!\": ")
string userInput = Console.ReadLine();
while(numbers >=1)
{
Console.WriteLine("Yay!");
numbers --;
}
try
{
int numbers= int.Parse(userInput);
}
catch(FormatException)
{
Console.WriteLine("You must enter a whole number.");
continue;
}
}
}
}
1 Answer
Steven Parker
231,269 PointsI see a few issues at first glance:
- you should convert the input into a number before the output loop that uses it
- you won't need "continue" in the catch block, that's only used inside loops