المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : plz help!!error use of unassigned local variable



C# Programming
04-07-2010, 09:21 AM
hi i just want to display all empty fieldnames that are not filled up by the user
but my code has this errorer ' use of unassigned local variable 'messEmptyField' ; how can i fix this



private void btnSave_Click(object sender, EventArgs e)
{
string[] FieldName = { "Lastname", "Firstname", "Address", "Model", "Trouble Reported" };
string messEmptyField;
int i = 0;

foreach (Control ctrl in groupBox1.Controls)
{
TextBox txt = ctrl as TextBox;

if (txt.Text == string.Empty)
{
messEmptyField += FieldName[i]; //error use of unassigned local variable 'messEmptyField'
}
i++;
}

MessageBox.Show(messEmptyField + "please filled up all");
dtDateLog.Focus();
return;
}