How do I cast a List effectively?

前端 未结 8 1425
暖寄归人
暖寄归人 2020-12-08 15:09

I have a

List 

but I need a

List  

Is there a way to cast this in c

8条回答
  •  孤街浪徒
    2020-12-08 15:43

    You could also use List.ConvertAll.

    Documentation: http://msdn.microsoft.com/en-us/library/73fe8cwf.aspx

    Example:

    List newList = oldList.ConvertAll(i => i as IDataField);
    

提交回复
热议问题