public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.Text = stu1[this.listBox1.SelectedIndex].classes;
}
student[] stu1=new student [3];
private void Form1_Load(object sender, EventArgs e)
{
stu1[0] = new student("s0", "c00");
stu1[1] = new student("s1", "c01");
stu1[2] = new student("s2", "c02");
for (int i = 0; i < stu1.Length; i++)
this.listBox1.Items.Add(stu1[i].name);
}
}
单独定义类,以三个学生为例。
温馨提示:答案为网友推荐,仅供参考