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# Basics (Retired) Perfect Variable Scope

stuck again...

I can't get my code to compile after I moved all my if/else if/if statements into my try{}catch{}. I'm not sure what I need to add or remove.

2 Answers

Steven Parker
Steven Parker
231,236 Points

Hi Jon,

I found these issues in your code:

  • the catch block should directly follow the try block
  • the catch block should be at the same level as the try block (not inside another block)
  • C# is case sensitive, so console.WriteLine needs to be Console.WriteLine
  • you were missing some ending braces (or had stray open braces)

You can see the code with those issues repaired in my answer to your other post.