ArrayList dynamic array
ArrayList is a dynamic array that can be used to store elements of any type. It provides many useful ways to easily add, delete and access elements.
Create a dynamic array
ArrayList list = new ArrayList();
Add Add append elements to the end of the array
for (int i = 0; i < 20; i++) { (i); //Add 20 elements to the array }
Count Get the current list
(); //20
Capacity is used to obtain the current internal capacity of the dynamic array (the upper limit of the number of elements that can be accommodated, not the number of elements that are currently actually contained.)
(); //32
IsFixedSize has a fixed size (returns a boolean value)
(); //false
IsReadOnly the read-only property of the array opens, returns a boolean value (not opened by default)
(); //false
IsSynchronized array supports synchronous access
(); //false
SyncRoot Gets an object that can be accessed
();
Insert: Insert elements into the index position established in the collection
Parameter 1: Representative index
Parameter 2: Inserted element
(0, 88);
Remove the specified first matching element from the collection. If it cannot be found, the collection remains unchanged.
(88);
RemoveAt Delete elements based on index
(0);
RemoveRange Removes a range of elements
The first parameter is the index at the beginning
The second parameter is the number of elements removed
(3, 2);
Contains Finds whether there is an element and returns a boolean value
((3));
IndexOf looks for the index of the element from front to back, and returns the index value when there exists, and returns -1 if there does not exist.
((4));d
LastIndexOf Find the index of an element. Return the index value when there exists, return -1 when there does not exist.
Parameter 1: Specify the element to be found
Parameter 2: Specify the location to start searching, and start the calculation from the end
When there is only one parameter, look up from behind to front
((7, 7)); //4
Clear Clear array
();
This is the end of this article about C# implementing ArrayList dynamic arrays. For more related C# ArrayList dynamic array content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!