Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
XML
Regex regex = new Regex("^[a-zA-Z0-9,-_ ]{2,12}$");
            return panel1.Controls.OfType<UserControl1>().Select(uc => uc.comboBox2).Any(cb => cb.Text == String.Empty);

as the code is for validation i am implementing this but i dont know how it works and where it flows. can anyone help me to understand this line

return panel1.Controls.OfType<UserControl1>().Select(uc => uc.comboBox2).Any(cb => cb.Text == String.Empty);
Posted
Updated 26-Feb-13 5:18am
v4

1 solution

The code
C#
panel1.Controls.OfType<usercontrol1>().Select(uc => uc.comboBox2).Any(cb => cb.Text == String.Empty);</usercontrol1>

can be splitted into three pieces:
C#
panel1.Controls.OfType<usercontrol1>()</usercontrol1>

filter[^] panel1 controls only of type UserControl1.
C#
.Select(uc => uc.comboBox2)

select[^] comboBox2 property/field of that UserControl1 instance.
C#
.Any(cb => cb.Text == String.Empty);

Check if any[^] satifies above condition (text is empty).
In human language (in reverse order): Check, if there is any occurrence of ComboBox with empty text inside controls of type UserControl1 within the panel1.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900