Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从列表中逐步删除所有项目并将已删除的项目添加到另一个列表,但我需要最大有效和高性能操作。什么是最佳实践?
您可以使用此代码并希望该框架能为您做到最好:
public static void MoveItems<T>(List<T> list1, List<T> list2) { list2.AddRange(list1); list1.Clear(); }
list2 = list1.ToList(); list1.Clear();