List<Empolyee> a=new List<Empolyee>();
a.add(new Employee());
a.add(new Employee());
object obj=a;
Type type=obj.Gettype();
读取List 中的信息.

解决方案 »

  1.   

    你要读取什么信息?
    每个EMPLOYEE么?
      

  2.   

    type.GetGenericArguments()[0]
    返回你EMPLOYEE的TYPE
      

  3.   

    Employee类的实现我没有,就拿char来写了段测试代码,你自己测试下,应该可以满足要求。
                List<char> list = new List<char>();
                list.Add('a');
                list.Add('b');
                list.Add('c');
                object a = list;
                int length = (int)a.GetType().GetProperty("Count").GetValue(a, null);
                for (int i = 0; i < length; i++)
                {
                    MessageBox.Show(a.GetType().GetProperty("Item").GetValue(a, new object[] { i }).ToString());
                }
      

  4.   

    谢谢....我就是想读取每一个Employee
      

  5.   

    foreach (Empolyee e in a){
        // ...
    }
      

  6.   

    List<Empolyee> a = new List<Empolyee>();
                a.Add(new Empolyee());
                a.Add(new Empolyee());
                object obj = a;
                Type type = obj.GetType();
                int length = (int)type.GetProperty("Count").GetValue(a, null);
                for (int i = 0; i < length; i++)
                {
                    Empolyee xx = type.GetProperty("Item").GetValue(a, new object[] { i }) as Empolyee;
                }