34

Possible Duplicate:
What is the difference between List (of T) and Collection(of T)?

What is the best practice for when to use one vs the other?

Both implement IList<T> and hold the data in an ordered fashion, but only List expose the sorting semantics....

Community
  • 1
  • 1
AndreasKnudsen
  • 3,453
  • 5
  • 28
  • 33

1 Answers1

25
  • Collection<T>:

    Provides the base class for a generic collection.

  • List<T>:

    Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.

So, according the docs, one is intended as a base class for collections. The other is intended for use as a container.

So use List<T> and inherit from Collection<T>.

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
OJ.
  • 28,944
  • 5
  • 56
  • 71
  • Btw, `Collection` implements the interface `IList` and has a `List` inside its implementation. (It's a facade wrapper class.) – JohnB Dec 06 '22 at 07:45