Cast IList to List

后端 未结 9 1703
时光取名叫无心
时光取名叫无心 2020-12-08 06:09

I am trying to cast IList type to List type but I am getting error every time.

List subProducts= Model.subproduct         


        
9条回答
  •  盖世英雄少女心
    2020-12-08 06:42

    List subProducts= (List)Model.subproduct;
    

    The implicit conversion failes because List<> implements IList, not viceversa. So you can say IList foo = new List(), but not List foo = (some IList-returning method or property).

提交回复
热议问题