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 trialDiego Roda
340 PointsWhy you declare variables at the beginning of the class and some other times within its loops or after other code lines?
I don't know if you mention it later on during the course, but the first occurrence came up during this lesson I think. Also, probably this is a OOP language-related concept, and not necessarily part of this course, but it'd be great to know the reason now that I'm learning it here.
1 Answer
Rick Hoekman
9,494 PointsYou will learn that with C# basics.. Some variables have to be in the body / block (within the {} ) to be available .. They call them Scopes. This is explained here: https://teamtreehouse.com/library/try-code-and-catch-exceptions