(webform)我如何从9个不同的文本框得到的值,并通过升序返回值
本文关键字:返回值 升序 文本 9个 webform | 更新日期: 2023-09-27 18:03:59
这是webform(asp.net c#)的代码:
protected void Button2_Click(object sender, EventArgs e)
{
int no1;
int no2;
int no3;
int no4;
int no5;
int no6;
int no7;
int no8;
int no9;
no1 = int.Parse(txt1.Text);
no2 = int.Parse(txt2.Text);
no3 = int.Parse(txt3.Text);
no4 = int.Parse(txt4.Text);
no5 = int.Parse(txt5.Text);
no6 = int.Parse(txt6.Text);
no7 = int.Parse(txt7.Text);
no8 = int.Parse(txt8.Text);
no9 = int.Parse(txt9.Text);
int[] a = new int[] {no1,no2,no3,no4,no5,no6,no7,no8,no9 };
Array.Sort(a);
foreach (var str in a)
{
MessageBox.Show(str.ToString()); //display in MessageBox, but i want to display back to 9 different textbox.
}
可以在MessageBox中显示结果。但我不能显示结果回到9个不同的文本框。我怎样才能找到解决办法呢?谢谢你!这是输出http://i.gyazo.com/a91f7ffef1d6d1fa7815890464df3082.png
txt1.Text = a[0];
txt2.Text = a[1];
txt3.Text = a[2];
txt4.Text = a[3];
txt5.Text = a[4];
txt6.Text = a[5];
txt7.Text = a[6];
txt8.Text = a[7];
txt9.Text = a[8];
如果我没理解错的话,这个应该可以了。