1.11M Members

what is the difference between list and arraylist in c#?

 
0
 

what is the difference between list and arraylist in c#?

 
0
 

F1 List and ArrayList and see what exactly the difference is :)

 
0
 

F1 List and ArrayList and see what exactly the difference is :)

In arrays you can have only one datatype(int, string,...) with many elements. But in Arraylist you can have different objects. So for storing different type of objects we can better use arraylist.

 
0
 

Well, to be more specific, EVERYTHING in an ArrayList gets stored as an object. The ArrayList is kind of like an Array that you can add objects to after you've instantiated it.

The ArrayList even has methods that you can use to convert the ArrayList to an Array. But, if you try to convert an ArrayList of objects that won't convert or cast to the type you're specifying to convert to, I imagine you'll get an exception thrown...

 
0
 

people question is diff between list and arrylist, why u guys are trying to give the differences for arrylist and arry ? plz let the answes be relevant...

thanku , plz don take it personal, but wat said makes sense right?
bye take care people

 
1
 

ArrayList stores everything as an object, and when you retrieve the value you have to cast it back into the actual object type if you want to use any of the objects methods, etc.

List<T> is a generic container type that you specify what type it can hold when you instantiate the List<T>. You don't have to cast the object back into the type.

I've never used ArrayList in anything I've written.

 
0
 

Me neither :)
List<T> is best option. Maybe for some "simple" arrays its better to use a simple array, like string[], or int[]. But if you have a custom object, List is better choice, and even better is a generic list (List<T> - as Momerath described in the previous post).

 
0
 

can u ppl simplfy your answers bit more . . .

You
Post:
Start New Discussion
Tags Related to this Article