views:

177

answers:

2

I have a doubt that what is an array and what is an ArrayList? What is the different between them?

A: 

is this for Java right? Well, I read somewhere that 1. ArrayList is a collection datatype which takes value/key pair. You need to use .Add property to add values to the arraylist collection. You can access the arraylist using keys. 2. Array is a datatype which can be accessed using indexes.

Roxy
is asp.net supported by Java? :) he tagged the question with asp.net
ArsenMkrt
Probably should be retagged to a specific .NET language, not ASP.NET
Yuriy Faktorovich
it is realted to .net not java
Surya sasidhar
tahnk u mr.Jacky i understood
Surya sasidhar
+4  A: 

An Array is a high performance way of storing a group of data with the same type because each element is laid out next to it's neighbor in memory. This allows for very fast access because (a) the code can do a little math and jump quickly to any location in the array, and (b) the elements are all grouped together so they tend to be in memory at the same time (fewer page faults and cache misses). An array in .NET is actually a class (System.Array), but a special type of class that is well understood by the .NET engine (CLR). Because of this, you can standard array access notation (text languages) such as foo[3] = 99;

In ArrayList, however, you are dealing with a collection. There are several types of collections in .NET (see the System.Collections and System.Collections.Specialized namespaces), but the key thing about them is the interfaces they support (IEnumerable, ICollections, IList, etc). If you look at the definition of these interfaces, you see that collections are all about grouping things together and providing methods to access them.With an ArrayList, however, if you add one element more than the internal array can handle, the ArrayList automatically creates a larger array and copies the old array into the new array.

ArsenMkrt
thank u mr arsenMkrt
Surya sasidhar