local and globle variables in C#

Local Variables

A local variable would be declared as:

typeName variableName  = variable initializer or
var variableName       = variable initializer

It may occur in a block, in a for statement, in a switch statement, or in a using statement. It can also occur in a foreach statement or a specific catch clause for a try statement:

Code Snippet
  1. void MethodA()
  2. {
  3.         int a=10;              /* Example of the local variable */
  4. }

Post a Comment