Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
When you create a variable with a declaration statement, .NET allocates enough memory to store the specified type’s properties and makes the identifier you’ve declared available for use. But declared elements don’t last forever, and you can’t access them from anywhere. The rule is simple: A variable is only visible within the context in which it’s defined. It’s a simple rule, so let’s look at a simple example: