How do I copy items from list to list without foreach?

后端 未结 8 1669
野的像风
野的像风 2020-11-30 17:42

How do I transfer the items contained in one List to another in C# without using foreach?

8条回答
  •  心在旅途
    2020-11-30 18:02

    And this is if copying a single property to another list is needed:

    targetList.AddRange(sourceList.Select(i => i.NeededProperty));
    

提交回复
热议问题