public class student 
        {
            private string _name;            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }
            private int _age;            public int Age
            {
                get { return _age; }
                set { _age = value; }
            }
            private Dictionary<string, student> _item;            public Dictionary<string, student> Item
            {
                get { return _item; }
                set { _item = value; }
            }
            public student(string _name,int _age,Dictionary<string ,student> _item) 
            {
                this.Name = _name;
                this.Age = _age;
                this.Item = _item;
            }
        }        private void Form1_Load(object sender, EventArgs e)
        {        }
       那么做属性的那个范型集合可以嘉甚么呀?  
           外面用的时候也要定义一字典范型集合、怎么添加?
        

解决方案 »

  1.   

    1.不应public出来这种集合类
    2.注意同步
      

  2.   

    如果你要直接用,一定要把_item这个东西先初始化(new出来),然后可以这样用:Student s = new Student();
    Student xm = new Student();
    Student xw = new Student();s.Add("小明", xm);
    s.Add("小文", xw);