​​Method Level Scope



A variable declared within a method has a method level Scope. It is also known as a local variable of the method where it is declared. It cannot be accessed outside the method.



Any nested code blocks within the method can access this type of variable. It cannot be declared twice with the same name within the same scope.



The local variable's scope ends when the method execution completes, and they will be collected by the garbage collector.



The following example shows the method Level scope.



In the above example, the Main() method can only access variables declared in the Main() method but not variables of other methods. In the same way, the Process() method cannot access variables declared in the Main() or any other method.