Find And Remove Items From Collection

后端 未结 4 1118
北荒
北荒 2021-01-07 22:15

What is the best way to remove a set from a collection, but still keep the items that were removed in a separate collection?

I have written an extension method that

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-07 22:58

    Depending upon the size of your collection, you might want to implement it as a HashSet rather than a List. In sufficiently large collections (how large is "sufficient" has been somewhat dependent on what is in the collection, in my experience), HashSets can be much, much faster at finding items within themselves than Lists.

提交回复
热议问题