Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Collections.​ArrayList

Assembly: System.Runtime

Inheritance: object → ArrayList

Implements the <see cref="T:System.Collections.IList" /> interface using an array whose size is dynamically increased as required.

Properties

public int
Capacity
Gets or sets the number of elements that the <see cref="T:System.Collections.ArrayList" /> can contain.
public int
Count
Gets the number of elements actually contained in the <see cref="T:System.Collections.ArrayList" /> .
public bool
IsFixedSize
Gets a value indicating whether the <see cref="T:System.Collections.ArrayList" /> has a fixed size.
public bool
IsReadOnly
Gets a value indicating whether the <see cref="T:System.Collections.ArrayList" /> is read-only.
public bool
IsSynchronized
Gets a value indicating whether access to the <see cref="T:System.Collections.ArrayList" /> is synchronized (thread safe).
public object
Item
public object
SyncRoot
Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ArrayList" /> .

Methods

public int
Add​(object value)
value The <see cref="T:System.Object" /> to be added to the end of the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
Returns The <see cref="T:System.Collections.ArrayList" /> index at which the <paramref name="value" /> has been added.
Adds an object to the end of the <see cref="T:System.Collections.ArrayList" /> .
public void
AddRange​(ICollection c)
c The <see cref="T:System.Collections.ICollection" /> whose elements should be added to the end of the <see cref="T:System.Collections.ArrayList" /> . The collection itself cannot be <see langword="null" /> , but it can contain elements that are <see langword="null" /> .
Adds the elements of an <see cref="T:System.Collections.ICollection" /> to the end of the <see cref="T:System.Collections.ArrayList" /> .
public int
BinarySearch​(int index, int count, object value, IComparer comparer)
index The zero-based starting index of the range to search.
count The length of the range to search.
value The <see cref="T:System.Object" /> to locate. The value can be <see langword="null" /> .
comparer The <see cref="T:System.Collections.IComparer" /> implementation to use when comparing elements. -or- <see langword="null" /> to use the default comparer that is the <see cref="T:System.IComparable" /> implementation of each element.
Returns The zero-based index of <paramref name="value" /> in the sorted <see cref="T:System.Collections.ArrayList" /> , if <paramref name="value" /> is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than <paramref name="value" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.Collections.ArrayList.Count" /> .
Searches a range of elements in the sorted <see cref="T:System.Collections.ArrayList" /> for an element using the specified comparer and returns the zero-based index of the element.
public int
BinarySearch​(object value)
value The <see cref="T:System.Object" /> to locate. The value can be <see langword="null" /> .
Returns The zero-based index of <paramref name="value" /> in the sorted <see cref="T:System.Collections.ArrayList" /> , if <paramref name="value" /> is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than <paramref name="value" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.Collections.ArrayList.Count" /> .
Searches the entire sorted <see cref="T:System.Collections.ArrayList" /> for an element using the default comparer and returns the zero-based index of the element.
public int
BinarySearch​(object value, IComparer comparer)
value The <see cref="T:System.Object" /> to locate. The value can be <see langword="null" /> .
comparer The <see cref="T:System.Collections.IComparer" /> implementation to use when comparing elements. -or- <see langword="null" /> to use the default comparer that is the <see cref="T:System.IComparable" /> implementation of each element.
Returns The zero-based index of <paramref name="value" /> in the sorted <see cref="T:System.Collections.ArrayList" /> , if <paramref name="value" /> is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than <paramref name="value" /> or, if there is no larger element, the bitwise complement of <see cref="P:System.Collections.ArrayList.Count" /> .
Searches the entire sorted <see cref="T:System.Collections.ArrayList" /> for an element using the specified comparer and returns the zero-based index of the element.
public void
Clear​()
Removes all elements from the <see cref="T:System.Collections.ArrayList" /> .
public object
Clone​()
Returns A shallow copy of the <see cref="T:System.Collections.ArrayList" /> .
Creates a shallow copy of the <see cref="T:System.Collections.ArrayList" /> .
public bool
Contains​(object item)
item The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
Returns <see langword="true" /> if <paramref name="item" /> is found in the <see cref="T:System.Collections.ArrayList" /> ; otherwise, <see langword="false" /> .
Determines whether an element is in the <see cref="T:System.Collections.ArrayList" /> .
public void
CopyTo​(Array array)
array The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.ArrayList" /> . The <see cref="T:System.Array" /> must have zero-based indexing.
Copies the entire <see cref="T:System.Collections.ArrayList" /> to a compatible one-dimensional <see cref="T:System.Array" /> , starting at the beginning of the target array.
public void
CopyTo​(Array array, int arrayIndex)
array The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.ArrayList" /> . The <see cref="T:System.Array" /> must have zero-based indexing.
arrayIndex The zero-based index in <paramref name="array" /> at which copying begins.
Copies the entire <see cref="T:System.Collections.ArrayList" /> to a compatible one-dimensional <see cref="T:System.Array" /> , starting at the specified index of the target array.
public void
CopyTo​(int index, Array array, int arrayIndex, int count)
index The zero-based index in the source <see cref="T:System.Collections.ArrayList" /> at which copying begins.
array The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.ArrayList" /> . The <see cref="T:System.Array" /> must have zero-based indexing.
arrayIndex The zero-based index in <paramref name="array" /> at which copying begins.
count The number of elements to copy.
Copies a range of elements from the <see cref="T:System.Collections.ArrayList" /> to a compatible one-dimensional <see cref="T:System.Array" /> , starting at the specified index of the target array.
public IEnumerator
GetEnumerator​()
Returns An <see cref="T:System.Collections.IEnumerator" /> for the entire <see cref="T:System.Collections.ArrayList" /> .
Returns an enumerator for the entire <see cref="T:System.Collections.ArrayList" /> .
public IEnumerator
GetEnumerator​(int index, int count)
index The zero-based starting index of the <see cref="T:System.Collections.ArrayList" /> section that the enumerator should refer to.
count The number of elements in the <see cref="T:System.Collections.ArrayList" /> section that the enumerator should refer to.
Returns An <see cref="T:System.Collections.IEnumerator" /> for the specified range of elements in the <see cref="T:System.Collections.ArrayList" /> .
Returns an enumerator for a range of elements in the <see cref="T:System.Collections.ArrayList" /> .
public ArrayList
GetRange​(int index, int count)
index The zero-based <see cref="T:System.Collections.ArrayList" /> index at which the range starts.
count The number of elements in the range.
Returns An <see cref="T:System.Collections.ArrayList" /> that represents a subset of the elements in the source <see cref="T:System.Collections.ArrayList" /> .
Returns an <see cref="T:System.Collections.ArrayList" /> that represents a subset of the elements in the source <see cref="T:System.Collections.ArrayList" /> .
public int
IndexOf​(object value)
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
Returns The zero-based index of the first occurrence of <paramref name="value" /> within the entire <see cref="T:System.Collections.ArrayList" /> , if found; otherwise, -1.
Searches for the specified <see cref="T:System.Object" /> and returns the zero-based index of the first occurrence within the entire <see cref="T:System.Collections.ArrayList" /> .
public int
IndexOf​(object value, int startIndex)
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
startIndex The zero-based starting index of the search. 0 (zero) is valid in an empty list.
Returns The zero-based index of the first occurrence of <paramref name="value" /> within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that extends from <paramref name="startIndex" /> to the last element, if found; otherwise, -1.
Searches for the specified <see cref="T:System.Object" /> and returns the zero-based index of the first occurrence within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that extends from the specified index to the last element.
public int
IndexOf​(object value, int startIndex, int count)
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
startIndex The zero-based starting index of the search. 0 (zero) is valid in an empty list.
count The number of elements in the section to search.
Returns The zero-based index of the first occurrence of <paramref name="value" /> within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that starts at <paramref name="startIndex" /> and contains <paramref name="count" /> number of elements, if found; otherwise, -1.
Searches for the specified <see cref="T:System.Object" /> and returns the zero-based index of the first occurrence within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that starts at the specified index and contains the specified number of elements.
public void
Insert​(int index, object value)
index The zero-based index at which <paramref name="value" /> should be inserted.
value The <see cref="T:System.Object" /> to insert. The value can be <see langword="null" /> .
Inserts an element into the <see cref="T:System.Collections.ArrayList" /> at the specified index.
public void
InsertRange​(int index, ICollection c)
index The zero-based index at which the new elements should be inserted.
c The <see cref="T:System.Collections.ICollection" /> whose elements should be inserted into the <see cref="T:System.Collections.ArrayList" /> . The collection itself cannot be <see langword="null" /> , but it can contain elements that are <see langword="null" /> .
Inserts the elements of a collection into the <see cref="T:System.Collections.ArrayList" /> at the specified index.
public int
LastIndexOf​(object value)
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
Returns The zero-based index of the last occurrence of <paramref name="value" /> within the entire the <see cref="T:System.Collections.ArrayList" /> , if found; otherwise, -1.
Searches for the specified <see cref="T:System.Object" /> and returns the zero-based index of the last occurrence within the entire <see cref="T:System.Collections.ArrayList" /> .
public int
LastIndexOf​(object value, int startIndex)
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
startIndex The zero-based starting index of the backward search.
Returns The zero-based index of the last occurrence of <paramref name="value" /> within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that extends from the first element to <paramref name="startIndex" /> , if found; otherwise, -1.
Searches for the specified <see cref="T:System.Object" /> and returns the zero-based index of the last occurrence within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that extends from the first element to the specified index.
public int
LastIndexOf​(object value, int startIndex, int count)
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
startIndex The zero-based starting index of the backward search.
count The number of elements in the section to search.
Returns The zero-based index of the last occurrence of <paramref name="value" /> within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that contains <paramref name="count" /> number of elements and ends at <paramref name="startIndex" /> , if found; otherwise, -1.
Searches for the specified <see cref="T:System.Object" /> and returns the zero-based index of the last occurrence within the range of elements in the <see cref="T:System.Collections.ArrayList" /> that contains the specified number of elements and ends at the specified index.
public void
Remove​(object obj)
obj The <see cref="T:System.Object" /> to remove from the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
Removes the first occurrence of a specific object from the <see cref="T:System.Collections.ArrayList" /> .
public void
RemoveAt​(int index)
index The zero-based index of the element to remove.
Removes the element at the specified index of the <see cref="T:System.Collections.ArrayList" /> .
public void
RemoveRange​(int index, int count)
index The zero-based starting index of the range of elements to remove.
count The number of elements to remove.
Removes a range of elements from the <see cref="T:System.Collections.ArrayList" /> .
public void
Reverse​()
Reverses the order of the elements in the entire <see cref="T:System.Collections.ArrayList" /> .
public void
Reverse​(int index, int count)
index The zero-based starting index of the range to reverse.
count The number of elements in the range to reverse.
Reverses the order of the elements in the specified range.
public void
SetRange​(int index, ICollection c)
index The zero-based <see cref="T:System.Collections.ArrayList" /> index at which to start copying the elements of <paramref name="c" /> .
c The <see cref="T:System.Collections.ICollection" /> whose elements to copy to the <see cref="T:System.Collections.ArrayList" /> . The collection itself cannot be <see langword="null" /> , but it can contain elements that are <see langword="null" /> .
Copies the elements of a collection over a range of elements in the <see cref="T:System.Collections.ArrayList" /> .
public void
Sort​()
Sorts the elements in the entire <see cref="T:System.Collections.ArrayList" /> .
public void
Sort​(IComparer comparer)
comparer The <see cref="T:System.Collections.IComparer" /> implementation to use when comparing elements. -or- A null reference ( <see langword="Nothing" /> in Visual Basic) to use the <see cref="T:System.IComparable" /> implementation of each element.
Sorts the elements in the entire <see cref="T:System.Collections.ArrayList" /> using the specified comparer.
public void
Sort​(int index, int count, IComparer comparer)
index The zero-based starting index of the range to sort.
count The length of the range to sort.
comparer The <see cref="T:System.Collections.IComparer" /> implementation to use when comparing elements. -or- A null reference ( <see langword="Nothing" /> in Visual Basic) to use the <see cref="T:System.IComparable" /> implementation of each element.
Sorts the elements in a range of elements in <see cref="T:System.Collections.ArrayList" /> using the specified comparer.
public object[]
ToArray​()
Returns An <see cref="T:System.Object" /> array containing copies of the elements of the <see cref="T:System.Collections.ArrayList" /> .
Copies the elements of the <see cref="T:System.Collections.ArrayList" /> to a new <see cref="T:System.Object" /> array.
public Array
ToArray​(Type type)
type The element <see cref="T:System.Type" /> of the destination array to create and copy elements to.
Returns An array of the specified element type containing copies of the elements of the <see cref="T:System.Collections.ArrayList" /> .
Copies the elements of the <see cref="T:System.Collections.ArrayList" /> to a new array of the specified element type.
public void
TrimToSize​()
Sets the capacity to the actual number of elements in the <see cref="T:System.Collections.ArrayList" /> .
public bool
Equals​(object obj)
Inherited from object
obj The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Returns A hash code for the current object.
Serves as the default hash function.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns A string that represents the current object.
Returns a string that represents the current object.