System.Collections.Concurrent.ConcurrentBag<T> Class

Represents a thread-safe, unordered collection of objects.

See Also: ConcurrentBag<T> Members


public class ConcurrentBag<T> : IProducerConsumerCollection<T>, IEnumerable<T>

Type Parameters

Documentation for this section has not yet been entered.


Bags are useful for storing objects when ordering doesn't matter, and unlike sets, bags support duplicates. System.Collections.Concurrent.ConcurrentBag`1 is a thread-safe bag implementation, optimized for scenarios where the same thread will be both producing and consuming data stored in the bag.

System.Collections.Concurrent.ConcurrentBag`1 accepts null as a valid value for reference types.

For more information, see the entry tp:// in the Parallel Programming with .NET blog.


Namespace: System.Collections.Concurrent
Assembly: System (in System.dll)
Assembly Versions: