我必须写一个程序(C#,WPF),其中数据被从〜30个文本框检索。我想通过循环文本框。我试图创建文本框的数组,但由于每一个方法,我不得不多次重新初始化这个数组它没有很好地工作。如何将多个文本框的内容读取到数组中?
TextBox[] subjects = { textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10 };
TextBox[] credits = { textBox11, textBox12, textBox13, textBox14, textBox15, textBox16, textBox17, textBox18, textBox19, textBox20 };
TextBox[] marks = { textBox21, textBox22, textBox23, textBox24, textBox25, textBox26, textBox27, textBox28, textBox29, textBox30 };
Subject.SubjectName = subjects[selection].Text;
Subject.AmountOfCredits= Convert.ToInt32(credits[selection].Text);
Subject.Mark = Convert.ToInt32(marks[selection].Text);
主要的问题是,如果有任何其他的方式来循环使用所有这些控件,而无需创建文本框的阵列?
在此先感谢。