In C#, is it possible to cast a List to List?

前端 未结 5 1951
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 05:29

I want to do something like this:

List childList = new List();
...
List parentList = childList;

How

5条回答
  •  悲&欢浪女
    2020-11-28 05:59

    You can do this by using a Linq approach of the apply extension method, i.e.:

    List parentList = childList.Cast().ToList();
    

提交回复
热议问题