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# Objects Inheritance Throwing Exceptions

Not really sure what to do here. any help

I'm confused with how to format the syntax of try and catch clauses

Program.cs
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
Steven Parker
231,271 Points

You'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
Steven Parker
231,271 Points

Daniel Kolb — Did this fix your issue? You can mark a question solved by choosing a "best answer".
And happy coding!