Difference between List and iList

lemming

New member
Joined
Mar 7, 2006
Messages
3
Programming Experience
3-5
What is the difference between list and ilist and when would you use one over the other.

To put my question in context, I am using a collection to store location names and GPS co-ordinates and am trying to understand the roles of iList, List ,Innerlist and Arraylist in relation to collections.

I can't find suitable explanations in Balenas book or other texts.
 
You have used a number of different keywords there, but the one they all have in common is ILIST. In that they all implement the ilist interface. That is where you should start your research. The reason they are what they are and they have the functionality that they do is because of the interface they implement.
 
If you're using VB 2005 then you shouldn't be using ArrayLists very much at all. An ArrayList is a generalised collection that can hold anything. In .NET 1.x, if you wanted to create your own ArrayList-like collection that was strongly typed you had to inherit CollectionBase, which kept an inner ArrayList but would only accept the specific types of objects that you prescribed. The InnerList property of CollectionBase is an ArrayList. In .NET 2.0 you don't have to do that in most instances because you have Generics. Let's say you wanted to create a collection that only accpeted objects of MyType. In .NET 1.x you would have had to create your own class derived from CollectionBase and code the majority of its members yourself. In .NET 2.0 you simply do this:
VB.NET:
Dim myCollection As List(Of MyType)
and that's it. The System.Collections.Generic.List(Of T) is like the ArrayList except that it will only accept object sof type T, which is a type that you specify when you declare the variable.
 
Back
Top