i have a windows form in which there are controls listed below panel1 button1 = add new mobiles button2 = ok When clicking on button1 an usercontrol is added. Y
int sum = 0; panel1.Controls.OfType().ToList().ForEach( x => { TextBox ctl = x.Controls.OfType().Where(y => y.Name == "textbox2").FirstOrDefault(); sum += (ctl == null ? 0 : (!String.IsNullOrEmpty(ctl.Text.Trim()) ? Convert.ToInt32(ctl.Text.Trim()) : 0)); } );