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

Implemented Interfaces

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 static ArrayList
Adapter​(IList list)
Creates an <see cref="T:System.Collections.ArrayList" /> wrapper for a specific <see cref="T:System.Collections.IList" /> .
Returns The <see cref="T:System.Collections.ArrayList" /> wrapper around the <see cref="T:System.Collections.IList" /> .
list The <see cref="T:System.Collections.IList" /> to wrap.
public int
Add​(object value)
Adds an object to the end of the <see cref="T:System.Collections.ArrayList" /> .
Returns The <see cref="T:System.Collections.ArrayList" /> index at which the <paramref name="value" /> has been added.
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" /> .
public void
AddRange​(ICollection c)
Adds the elements of an <see cref="T:System.Collections.ICollection" /> to the end of the <see cref="T:System.Collections.ArrayList" /> .
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" /> .
public int
BinarySearch​(int index, int count, object value, IComparer comparer)
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.
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" /> .
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.
public int
BinarySearch​(object value)
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.
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" /> .
value The <see cref="T:System.Object" /> to locate. The value can be <see langword="null" /> .
public int
BinarySearch​(object value, IComparer comparer)
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.
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" /> .
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.
public void
Clear​()
Removes all elements from the <see cref="T:System.Collections.ArrayList" /> .
public object
Clone​()
Creates a shallow copy of the <see cref="T:System.Collections.ArrayList" /> .
Returns A shallow copy of the <see cref="T:System.Collections.ArrayList" /> .
public bool
Contains​(object item)
Determines whether an element is in the <see cref="T:System.Collections.ArrayList" /> .
Returns <see langword="true" /> if <paramref name="item" /> is found in the <see cref="T:System.Collections.ArrayList" /> ; otherwise, <see langword="false" /> .
item The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
public void
CopyTo​(Array array)
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.
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.
public void
CopyTo​(Array array, int arrayIndex)
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.
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.
public void
CopyTo​(int index, Array array, int arrayIndex, int count)
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.
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.
public static ArrayList
FixedSize​(ArrayList list)
Returns an <see cref="T:System.Collections.ArrayList" /> wrapper with a fixed size.
Returns An <see cref="T:System.Collections.ArrayList" /> wrapper with a fixed size.
list The <see cref="T:System.Collections.ArrayList" /> to wrap.
public static IList
FixedSize​(IList list)
Returns an <see cref="T:System.Collections.IList" /> wrapper with a fixed size.
Returns An <see cref="T:System.Collections.IList" /> wrapper with a fixed size.
list The <see cref="T:System.Collections.IList" /> to wrap.
public IEnumerator
GetEnumerator​()
Returns an enumerator for the entire <see cref="T:System.Collections.ArrayList" /> .
Returns An <see cref="T:System.Collections.IEnumerator" /> for the entire <see cref="T:System.Collections.ArrayList" /> .
public IEnumerator
GetEnumerator​(int index, int count)
Returns an enumerator for a range of elements in the <see cref="T:System.Collections.ArrayList" /> .
Returns An <see cref="T:System.Collections.IEnumerator" /> for the specified range of elements in the <see cref="T:System.Collections.ArrayList" /> .
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.
public ArrayList
GetRange​(int index, int count)
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" /> .
index The zero-based <see cref="T:System.Collections.ArrayList" /> index at which the range starts.
count The number of elements in the range.
public int
IndexOf​(object value)
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" /> .
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.
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
public int
IndexOf​(object value, int startIndex)
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.
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.
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.
public int
IndexOf​(object value, int startIndex, int count)
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.
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.
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.
public void
Insert​(int index, object value)
Inserts an element into the <see cref="T:System.Collections.ArrayList" /> at the specified index.
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" /> .
public void
InsertRange​(int index, ICollection c)
Inserts the elements of a collection into the <see cref="T:System.Collections.ArrayList" /> at the specified index.
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" /> .
public int
LastIndexOf​(object value)
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" /> .
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.
value The <see cref="T:System.Object" /> to locate in the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
public int
LastIndexOf​(object value, int startIndex)
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.
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.
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.
public int
LastIndexOf​(object value, int startIndex, int count)
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.
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.
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.
public static ArrayList
ReadOnly​(ArrayList list)
Returns a read-only <see cref="T:System.Collections.ArrayList" /> wrapper.
Returns A read-only <see cref="T:System.Collections.ArrayList" /> wrapper around <paramref name="list" /> .
list The <see cref="T:System.Collections.ArrayList" /> to wrap.
public static IList
ReadOnly​(IList list)
Returns a read-only <see cref="T:System.Collections.IList" /> wrapper.
Returns A read-only <see cref="T:System.Collections.IList" /> wrapper around <paramref name="list" /> .
list The <see cref="T:System.Collections.IList" /> to wrap.
public void
Remove​(object obj)
Removes the first occurrence of a specific object from the <see cref="T:System.Collections.ArrayList" /> .
obj The <see cref="T:System.Object" /> to remove from the <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
public void
RemoveAt​(int index)
Removes the element at the specified index of the <see cref="T:System.Collections.ArrayList" /> .
index The zero-based index of the element to remove.
public void
RemoveRange​(int index, int count)
Removes a range of elements from the <see cref="T:System.Collections.ArrayList" /> .
index The zero-based starting index of the range of elements to remove.
count The number of elements to remove.
public static ArrayList
Repeat​(object value, int count)
Returns an <see cref="T:System.Collections.ArrayList" /> whose elements are copies of the specified value.
Returns An <see cref="T:System.Collections.ArrayList" /> with <paramref name="count" /> number of elements, all of which are copies of <paramref name="value" /> .
value The <see cref="T:System.Object" /> to copy multiple times in the new <see cref="T:System.Collections.ArrayList" /> . The value can be <see langword="null" /> .
count The number of times <paramref name="value" /> should be copied.
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)
Reverses the order of the elements in the specified range.
index The zero-based starting index of the range to reverse.
count The number of elements in the range to reverse.
public void
SetRange​(int index, ICollection c)
Copies the elements of a collection over a range of elements in the <see cref="T:System.Collections.ArrayList" /> .
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" /> .
public void
Sort​()
Sorts the elements in the entire <see cref="T:System.Collections.ArrayList" /> .
public void
Sort​(IComparer comparer)
Sorts the elements in the entire <see cref="T:System.Collections.ArrayList" /> using the specified 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.
public void
Sort​(int index, int count, IComparer comparer)
Sorts the elements in a range of elements in <see cref="T:System.Collections.ArrayList" /> using the specified 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.
public static ArrayList
Synchronized​(ArrayList list)
Returns an <see cref="T:System.Collections.ArrayList" /> wrapper that is synchronized (thread safe).
Returns An <see cref="T:System.Collections.ArrayList" /> wrapper that is synchronized (thread safe).
list The <see cref="T:System.Collections.ArrayList" /> to synchronize.
public static IList
Synchronized​(IList list)
Returns an <see cref="T:System.Collections.IList" /> wrapper that is synchronized (thread safe).
Returns An <see cref="T:System.Collections.IList" /> wrapper that is synchronized (thread safe).
list The <see cref="T:System.Collections.IList" /> to synchronize.
public object[]
ToArray​()
Copies the elements of the <see cref="T:System.Collections.ArrayList" /> to a new <see cref="T:System.Object" /> array.
Returns An <see cref="T:System.Object" /> array containing copies of the elements of the <see cref="T:System.Collections.ArrayList" /> .
public Array
ToArray​(Type type)
Copies the elements of the <see cref="T:System.Collections.ArrayList" /> to a new array of the specified element type.
Returns An array of the specified element type containing copies of the elements of the <see cref="T:System.Collections.ArrayList" /> .
type The element <see cref="T:System.Type" /> of the destination array to create and copy elements to.
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
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with 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
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns 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.