Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# list arrays
I require a fast speed in processing my page. Which one of the above is preferred? Support with a valid reason.
 
Edit: For eg:
 
string str = "a,b,c"; //Count of the number of elements in str is not fixed
string[] arr = str.Split(',');
 
ArrayList al = new ArrayList();
al.Add(str.Split(','));
 
Which of them gives faster results?
Posted 30-May-12 2:43am
Edited 30-May-12 4:10am
v3
Comments
Sunnykumar08 at 30-May-12 7:58am
   
depends on what kind of processing do you need to do...please expose some details the subject so that we can have a better picture to help you :)
Member 8491154 at 31-May-12 1:16am
   
i have posted an example
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

The capacity of an Array is fixed.
Where as, ArrayList can increase and decrease size dynamically.
 
An Array is a collection of similar items.
Where as, ArrayList can hold item of different types.
 
Array is in the System namespace.
Where as, ArrayList is in the System.Collections namespace.
 
An Array can have multiple dimensions.
Where as, ArrayList always has exactly one dimension.
 
We can set the lower bound of an Array.
Where as, the lower bound of an ArrayList is always zero.
 
Array is faster and that is because ArrayList uses a fixed amount of array.
However when you add an element to the ArrayList and it overflows. It creates a new Array and copies every element from the old one to the new one.
You will only feel this if you add to often.
 
Since the add from ArrayList is O(n) and the add to the Array is O(1).
 
However because ArrayList uses an Array is faster to search O(1) in it than normal lists O(n).
 
List over arrays.
If you do not exceed the capacity it is going to be as fast as an array.
Better handling and much easier way of doing things.
 
Please refer:
ArrayList and List Collection Types[^]
  Permalink  
Comments
Member 8491154 at 30-May-12 9:21am
   
I have heard that ArrayList has become obsolete. Is it true?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Looks like a small world out there.. I guess you have asked the same question in the following sites also...
 
http://forums.asp.net/p/1808968/5004003.aspx/1?Which+is+better+array+ArrayList+or+List+T+in+terms+of+performance+and+speed+
 

http://stackoverflow.com/questions/10815565/which-is-better-array-arraylist-or-listt-in-terms-of-performance-and-speed
 

Array is undoubtadly faster than the other two. List is much more sophisticated than array / arraylist.. Arraylist is in between blending the speed of array and convenience of List
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

The highest performing collection is the hashtable. Arrays, Arraylists and lists are collections of objects which means finding them again is slower than using a key in an optimised collection such as the hashtable.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 30 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100