我定义了List<>集合,集合中的元素是我自定义的类,我想修改集合中某个元素的某个属性的值。
我直接用 集合[元素序号].属性 = 值 
可是没效果,元素的值还是没改变,怎么回事儿呢?请教朋友们,谢谢!

解决方案 »

  1.   

    class Student
        {
            public String name;
            public int stdID;
        }    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                List<Student> list = new List<Student>();
                list.Add(new Student());
                list[0].name = "Test";
                label1.Text = list[0].name;
            }    }
    我试了一下,可以正确使用的。