What is a local variable and where can it be declared in C#?
Experience Level: Junior
Tags: C#
Answer
In C#, local variable is a variable that is declared within a method. Such variable is then visible to and accessible from the rest of the code that is below the variable declaration. If you declare a local variable inside of a nested block statement, then this variable will be visible to and accessible from the rest of the code that is below the variable declaraion but only in the same or other nesed block statement.
Related C# job interview questions
What do you know about methods in C#?
C# JuniorWhat is execution context in C#?
C# JuniorWhat is a global variable and where can it be declared in C#?
C# JuniorWhat does the method signature consist of in C#?
C# JuniorWhat does the method consist of in C#?
C# Junior