How to remove a single, specific object from a ConcurrentBag<>?

后端 未结 9 602
误落风尘
误落风尘 2021-02-02 04:34

With the new ConcurrentBag in .NET 4, how do you remove a certain, specific object from it when only TryTake() and TryPeek() are

9条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-02 05:16

    how about:

    bag.Where(x => x == item).Take(1);
    

    It works, I'm not sure how efficiently...

提交回复
热议问题