The collection classes are special-purpose classes that are useful for storing data, dynamically allocating memory, retrieving a list of items or elements on the basic index number, etc. Furthermore, the collection classes also support Lists, ArrayList, Hash tables, queues, stacks, etc. that apply to the same interface.
The arrayList is an ordered collection of data elements that can be indexed individually in a list. The flexible data structure allows multiple objects to be added in a list without any size information. It is similar to the array. With the use of indexes in the ArrayList, we can add or remove an element from the list's specified location. Further, it also allows search, sort, add, and dynamic memory allocation in the ArrayList.
Uses of ArrayList
The following are the important uses of the ArrayList object.
1. Add: Add a data element to ArrayList.
2. Insert: Insert data element at specified location of ArrayList.
3. Remove: Remove an element from ArrayList.
4. RemoveAt: Remove data elements from the specified location of ArrayList.
indexNo: It represents the specified position of the item to be removed from the ArrayList.
5. Sort(): As the name suggests, it is used to sort all elements of the ArrayList.
Properties of the ArrayList Class
Following are the property of the ArrayList Class in the VB.NET
Methods of the ArrayList class
Following are the various methods of the ArrayList Class in the VB.NET
Method Name and their description
1. Add() Method: The Add() function is used to add an item to the end of the ArrayList.
2. Clear() Method: The Clear() method is used to clear all the elements from the ArrayList
3. Insert() Method: The Insert() method is used to insert an element into the specified location of the ArrayList.
4. Contains() Method: The Contains() Method is used to check whether the specified element exists in the ArrayList.
5. Remove() Method: The Remove() Method is used to remove a specified element from the ArrayList.
6. InsertRange() Method: The InsertRange() method is used to insert the collections of elements at the specified location in the ArrayList.
7. RemoveRange() Method: The RemoveRange() method is used to set a range for removing the elements from the ArrayList.
8. Reverse() Method: The Reverse() Method is used to reverse the order of the elements to the ArrayList.
9. RemoveAt() Method: The RemoveAt() method is used to remove an array element from the specified index of the ArrayList.
Let's create a program to understand the various function of ArrayList in the VB.NET programming language.