C# Compiler Error
CS0136 – A local variable named ‘var’ cannot be declared in this scope because it would give a different meaning to ‘var’, which is already used in a ‘parent or current/child’ scope to denote something else
Reason for the Error
You will receive this error in your C# code when a variable that you have declared hides another declaration with-in the same scope.
For example, try compiling the below code snippet.
namespace DeveloperPublishNamespace
{
public class DeveloperPublish
{
public static int i = 0;
public static void Main()
{
int var1 = 0;
{
int var1 = 78;
}
var1++;
}
}
}You will receive the below error as the variable var1 is already declared with-in the Main() function. The 2nd declaration of var1 results in this error.

Error CS0136 A local or parameter named ‘var1’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter ConsoleApp1 C:\Users\SenthilBalu\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 10 Active
Solution
To fix the error code CS0136, you will need to rename the variable that is causing issues.