A local or parameter named 'e' cannot be declared in this scope

Viewed 28921

I'm trying to use this code:

var controls = new[] { txtName, txtIdentityCard, txtMobile1 };
foreach (var control in controls.Where(e => String.IsNullOrEmpty(e.Text))) // error here in (e)
{
    errorProvider1.SetError(control, "Please fill the required field");
}

to check if one of my textboxes is empty, but it gives the following error:

A local or parameter named 'e' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter

Any help?

1 Answers
Related