shiva
shiva

Reputation: 764

Which collection does not implement IEnumerable

Is there any type of collection under System.Collections that does not inherit from IEnumerable or IEnumerable<T>?

I need an example.

Upvotes: 1

Views: 3063

Answers (1)

Jamiec
Jamiec

Reputation: 136104

No class directly inside System.Collections will implement IEnumerable<T> - that namespace predates generics in .NET - however the classes which could roughly be defined "Collections" in that namespace all implement IEnumerable

  • ArrayList
  • BitArray
  • CollectionBase
  • DictionaryBase
  • Hashtable
  • Queue
  • ReadOnlyCollectionBase
  • SortedList
  • Stack

If we expand to "Any namespace below System.Collections" we get into System.Collections.Generic and System.Collections.ObjectModel and System.Collections.Specialized - all the collections classes inside them implement IEnumerable, IEnumerable<T> or both.

Upvotes: 8

Related Questions