.netconcurrent-collections

Why does BlockingCollection<T> not implement ICollection<T>?


The current implementation looks like this:

public class BlockingCollection<T> : IEnumerable<T>, ICollection, IEnumerable, IDisposable

Does anyone have an idea why it does not implement ICollection<T> as well? It's kind of anoying...


Solution

  • For one it does not implement ICollection.Contains Method (T)
    As commented by Hans Contains() method cannot be implemented in an efficient thread-safe way.