IList, IDictionary, ...

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

What are the differences between IList and List or IDictionary and
dictionary?
The differences have something to do with Linq?

Which ones should I use?

Thanks,
Miguel
 
List realises IList, as do other classes such as
Array
ArrayList
List<T>
TreeNodeCollection

and others

If you want to accept a list of items in a parameter use IList, if you want
to create an object capable of holding a list of items you would be better
off with List<T>
 
Hello,

What are the differences between IList and List or IDictionary and
dictionary?
The differences have something to do with Linq?

Which ones should I use?

Thanks,
Miguel

Hi,

I* are interfaces, they do not provide an implementation. List
provides an implementation of that interface (the same with
IDictionary).
This allow for flexibility. For example you could implement a class
that implement IList but use different way to store the values for
example a linked list, or maybe using a tree.
The code that use those classes do not need to be changed cause it
uses a IList.
 
Back
Top