Search code examples
c#arraylistilist

Should I use an ArrayList or IList


Im using the .NET framework 1.1 and Im hoping someone could help me implement a dynamic array of objects?

A watered-down example of the object I wish use is below.

Class CarObj
{
   public string CarName;
   public string CarYear;
}

Should I use an ArrayList or do you think it would be better to make a CarList class to implement an IList interface? Is there a performance benefit for one over another?


Solution

  • Inherit CollectionBase instead; this wraps IList and allows you to provide your own implementation of typed methods you need. This is what it's designed for :)