Xiaoliang Ma

Xiaoliang Ma

  • NA
  • 6
  • 3k

WPF, count number of empty textbox and ComboBox

Jul 26 2018 9:24 PM
I have a C# WPF application with 400+ textbox and combo box. I need to count number of empty or null textbox and combo box. i have below code to count. but the problem is i have 400+ tests. It doesnt look like "smart" code if I follow the same way to count 400+ textboxes. Is there a better way to handle this case? Any help are much appreciated
 
 
int i = 0;
if (!String.IsEmptyorNull(txtBox1.Text))
{
i++;
}
else
{
if (!String.IsNullOrEmpty(txtBox2.Text))
i++;
}
txtTotal = i.ToString();

Answers (1)