1
Answer

WPF, count number of empty textbox and ComboBox

Xiaoliang Ma

Xiaoliang Ma

6y
1.1k
1
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)