ERROR Message: A local variable named 'e' cannot be declared in this scope because it would give a different meaning to 'e', which is already used in a 'parent or current' scope to denote something else. Why I'm seeing this error? How to remove. Please help. I'm new. Happy to see elaborate answer.
protected void ButtonDeleteProfile_Click(object sender, EventArgs e)
{
string inputString;
inputString = TextBoxInputEmployeeID.Text;
int inputEmployeeID;
int.TryParse(inputString, out inputEmployeeID);
TBL_EMPLOYEE deleteprofile = new TBL_EMPLOYEE();
TBL_EMPLOYEE_EDUCATION deleteEducation = new TBL_EMPLOYEE_EDUCATION();
TBL_LEAVEAPPLICATION deleteApplication = new TBL_LEAVEAPPLICATION();
TBL_LogIn deleteLoginInfo = new TBL_LogIn();
deleteEducation = hrmsDB.TBL_EMPLOYEE.Where(e => e.EmployeeID==inputEmployeeID).FirstOrDefault();
}
You've already got a method parameter called e
, so you can't introduce a lambda expression parameter called e
. You'll need to rename one of them.
As a shorter example, to show this has nothing to do with EF etc:
// Invalid: same variable name twice
void Foo(string x)
{
Action<int> action = x => {};
}
// Valid: different variable names
static void Foo(string x)
{
Action<int> action = y => {};
}
See more on this question at Stackoverflow