Click here to Skip to main content
12,395,645 members (78,642 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
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();

Which of them gives faster results?
Posted 30-May-12 1:43am
Updated 30-May-12 3:10am
Sunnykumar08 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 31-May-12 1:16am
i have posted an example
Rate this: bad
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[^]
Member 8491154 30-May-12 9:21am
I have heard that ArrayList has become obsolete. Is it true?
Rate this: bad
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...

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
Rate this: bad
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 30 May 2012
Copyright © CodeProject, 1999-2016
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