1,105,450 Community Members

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

Member Avatar
gurusamy
Newbie Poster
9 posts since May 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
mariocatch
Junior Poster
103 posts since Apr 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Arunkumar.K
Newbie Poster
1 post since Nov 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
alc6379
Cookie... That's it
2,752 posts since Dec 2003
Reputation Points: 105 [?]
Q&As Helped to Solve: 154 [?]
Skill Endorsements: 4 [?]
Team Colleague
 
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...

Member Avatar
rajani16
Newbie Poster
1 post since Feb 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Momerath
Senior Poster
3,831 posts since Aug 2010
Reputation Points: 1,327 [?]
Q&As Helped to Solve: 664 [?]
Skill Endorsements: 19 [?]
Featured
 
0
 

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.

Member Avatar
Mitja Bonca
Posting Maven
2,561 posts since May 2009
Reputation Points: 557 [?]
Q&As Helped to Solve: 489 [?]
Skill Endorsements: 21 [?]
 
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).

Member Avatar
Chetan Pai
Newbie Poster
1 post since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

can u ppl simplfy your answers bit more . . .

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article