解决方案 »

  1.   

    直接强制转换就可以了,
           foreach (T item in List<T>doctorlist)
                      {                  }
      

  2.   


    但是,doctorlist里面的信息的类型是其他网站的,比如说 这个 doctorlist就是list<ysxx>
    但是本站的类似 doctor  2个类的字段都是一样的。 直接强制转换的话会出错。
      

  3.   


     object doctorlist=  GetNewDoctors("http://localhost:4502/test/ok.asmx", "GetYsxx",null);    
                      IEnumerable<object> list = doctorlist as IEnumerable<object>;                  foreach (var dtItem in list)
                      {                      DDoctor dt = new DDoctor();
                          Type tp = dtItem.GetType();
                          Object obj = Activator.CreateInstance(tp);                   
                          dt.DtKey = dtItem.GetType().GetField("Ysid").GetValue(dtItem).ToString();
                          dt.DtName = dtItem.GetType().GetField("Ysxm").GetValue(dtItem).ToString();
    已用反射解决。
      

  4.   

    兄弟仗义,刚好用到了,想问一下你GetNewDoctors这个函数返回的是什么值