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 trialDaniel Kolb
10,172 PointsNot really sure what to do here. any help
I'm confused with how to format the syntax of try and catch clauses
if (!(int value < 0 || int value > 20))
{
throw new System.Exception();
}
try
{
value = int.Parse(Console.ReadLine());
Console.WriteLine(string.Format("You entered {0}",value));
}
catch(Exception)
{
}
1 Answer
Steven Parker
231,275 PointsYou're over-thinking this. The challenge is just to create the code to throw the exception, you won't need to use "try" or "catch" here. A few more hints:
- you code needs to go between the assignment and the output
- since the variable has already been declared, you won't need the "int" keywords
- recheck the test logic, the inversion is not needed
Steven Parker
231,275 PointsSteven Parker
231,275 PointsDaniel Kolb — Did this fix your issue? You can mark a question solved by choosing a "best answer".
And happy coding!