array vs arrylist
Arrays are of fixed size. Sometimes, they create some limitations when used in applications. The major limitation is that when we add more number of items to an array than the original size of the array, arrays cannot resize themselves automatically.However, to resize the array there is a ReDim statement available in vb.net. The ReDim statement resizes the original size of the array. When we execute the ReDim statement, the array loses it's data. So, we use the Preserve keyword along with ReDim statement as shown below.
ReDim Preserve myarray(Ubound(myArray + 1)
This concept is not available in C#.
ArrayList is similar to an array but grows automatically as the number of items are added to the arrayList. We can add, insert and delete items into an ArrayList very easily. And ArrayList stores any type of data inherited from System.Object. In a single Arraylist we can store any data type - integer, string and any type of object inherited from System.Object.
Briefly, an array contains one datatype whereas arraylist can contain many data types, the data in an array is accessed by indexes. Traversing the data in the ararylist can be done by using for..each loop or using enumerators or using indexers.
If you delete an item in an array, it keeps that position empty, whereas in an arraylist that position is occupied by the next element.
Lastly, adding, deleting items in an array is difficult but an arraylist provides methods for adding, deleting and inserting items.
What is the difference between Array and Arraylist? dealt with here on this page - array and arraylist difference
ArrayList Articles
- convert dataset to arraylist in asp.net using c#
- how to retrieve arraylist items in reverse order
- difference between arraylist and list collection
- how to create and add items into the ArrayList in csharp
- how to add items to the arraylist using an add method
- retrieve arraylist items using enumerators
- retrieve arraylist items using for each loop
- retrieve arraylist items using indexers
- insert items to the arraylist using insert and insertrange method
- remove items from arraylist
- find item in arraylist using indexof method
- bind arraylist with gridview control in asp net application
- how to bind arraylist with dropdownlist in asp net application
- how to bind arraylist with radiobuttonlist in asp.net application
- convert arraylist to string array
- convert string array to arraylist
- convert datatable into an arraylist
Most Viewed
Azure Q & A
Azure Platform
Grid-View
GridView CommandField example
Details-View
GridView and DetailsView Master/Detail page using SqlDataSource control
POCO
POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
Entity Framework
Query entity data model using linq to entities
Array List
Difference between arraylist and list collection
Web Services
How to create a Web service using Visual Studio.net
Form-View
FormView DataBound Event
Object Oriented Programming
Calling base class constructor in C#
Linq
Convert a sequence to a generic list using ToList()method
Project Ideas
Project ideas for students
AccountingSoftware
Accounting Software
MVC
Creating an ASP.Net MVC 3 application
.Net
Using assemblies in .net applications
ASP .Net
How to implement form validation using ASP.Net 2.0 Validation Controls