IList, IDictionary, ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    IList, IDictionary, ...

    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
  • Peter Morris

    #2
    Re: IList, IDictionary, ...

    List realises IList, as do other classes such as
    Array
    ArrayList
    List<T>
    TreeNodeCollect ion

    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>



    --
    Pete
    ====



    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: IList, IDictionary, ...

      On Oct 3, 1:59 pm, shapper <mdmo...@gmail. comwrote:
      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.

      Comment

      Working...