-1
に宣言することはできません私はこのコードを使用しようとしている:私のテキストボックスのいずれかが空であるが、それは次のエラーを与えるかどうかを確認するために「E」という名前のローカルまたはパラメータがこの範囲
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");
}
を
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
助けてください?
他にもいろいろあります。コードは1つずつうまく動作します...すべてのテキストボックスにエラーを設定する必要があります。そのうちの1つがいっぱいになるとエラーマークがクリアされます –
@a_fathyこの 'errorProvider1.Clear();を以下の' var controls = new [] {txtName、txtIdentityCard、txtMobile1}; 'と' foreach'の上に追加してください。 –