110,535
社区成员
发帖
与我相关
我的任务
分享
dynamic[] tbs = new dynamic[] { textBox1, textBox2, textBox3, textBox4, comboBox1 };
if (rbs.Any(x => x.Text == ""))
{
tbs.Where(x => x.Text == "").Tolist().ForEach(x => MessageBox.Show(x.Name));
}
foreach(Control c in this.Controls)
{
if(c is TextBox || c is ComboBox)
{
if(string.IsNullOrEmpty(c.Text))
MessageBox.Show(c.Name);
}
}
TextBox tb1, tb2, tb3, tb4;
ComboBox cb;
//initialize text box
//todo...
var tbArray = new Control[] { tb1, tb2, tb3, tb4, cb };
var msg = string.Join(",", (from ctrl in tbArray where string.IsNullOrEmpty(ctrl.Text) select ctrl.Name));
if (!string.IsNullOrEmpty(msg))
{
MessageBox.Show(msg);
}
TextBox[] tbs = new TextBox[] { textBox1, textBox2, textBox3, textBox4 };
if (rbs.Any(x => x.Text == ""))
{
tbs.Where(x => x.Text == "").Tolist().ForEach(x => MessageBox.Show(x.Name));
}
TextBox[] textboxes = { textBox1, textBox2, textBox3, textBox4};
foreach(TextBox tb in textboxes)
{
if(string.IsNullOrEmpty(tb.Text))
{
MessageBox.Show(tb.Name);
}
}