public static void SendDataFromHostelTextBox(Control parent) { int i = 0; foreach (Control c in parent.Controls) { if (c.GetType() == typeof(TextBox)) { i++; } } string[] mass = new string[i]; foreach (Control c in parent.Controls) { if (c.GetType() == typeof(TextBox)) { TextBox textBox = new TextBox(); textBox = (TextBox)c; mass[textBox.TabIndex - 1] = textBox.Text; } } BusinessClass.DataInForHostel(mass); }