Search Results for

    Show / Hide Table of Contents

    Class ArrayList

    Implements the IList interface using an array whose size is dynamically increased as required.

    Inheritance
    object
    ArrayList
    Implements
    IList
    ICollection
    IEnumerable
    ICloneable
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: System.Collections
    Assembly: mscorlib.dll
    Syntax
    public class ArrayList : IList, ICollection, IEnumerable, ICloneable

    Constructors

    ArrayList()

    Initializes a new instance of the ArrayList class that is empty and has the default initial capacity.

    Declaration
    public ArrayList()

    Properties

    Capacity

    Gets or sets the number of elements that the ArrayList can contain.

    Declaration
    public virtual int Capacity { get; set; }
    Property Value
    Type Description
    int

    The number of elements that the ArrayList can contain.

    Count

    Gets the number of elements actually contained in the ArrayList.

    Declaration
    public virtual int Count { get; }
    Property Value
    Type Description
    int

    The number of elements actually contained in the ArrayList.

    IsFixedSize

    Gets a value indicating whether the ArrayList has a fixed size.

    Declaration
    public virtual bool IsFixedSize { get; }
    Property Value
    Type Description
    bool

    true if the ArrayList has a fixed size; otherwise, false. The default is false.

    IsReadOnly

    Gets a value indicating whether the ArrayList is read-only.

    Declaration
    public virtual bool IsReadOnly { get; }
    Property Value
    Type Description
    bool

    true if the ArrayList is read-only; otherwise, false. The default is false.

    IsSynchronized

    Gets a value indicating whether access to the ArrayList is synchronized (thread safe).

    Declaration
    public virtual bool IsSynchronized { get; }
    Property Value
    Type Description
    bool

    true if access to the ArrayList is synchronized (thread safe); otherwise, false. The default is false.

    this[int]

    Gets or sets the element at the specified index.

    Declaration
    public virtual object this[int index] { get; set; }
    Parameters
    Type Name Description
    int index

    The zero-based index of the element to get or set.

    Property Value
    Type Description
    object

    SyncRoot

    Gets an object that can be used to synchronize access to the ArrayList.

    Declaration
    public virtual object SyncRoot { get; }
    Property Value
    Type Description
    object

    An object that can be used to synchronize access to the ArrayList.

    Methods

    Add(object)

    Adds an object to the end of the ArrayList.

    Declaration
    public virtual int Add(object value)
    Parameters
    Type Name Description
    object value
    Returns
    Type Description
    int

    The object to be added to the end of the ArrayList. The value can be null.

    BinarySearch(object, IComparer)

    Searches the entire sorted ArrayList for an element using the specified comparer and returns the zero-based index of the element.

    Declaration
    public virtual int BinarySearch(object value, IComparer comparer)
    Parameters
    Type Name Description
    object value

    The Object to locate. The value can be null reference (Nothing in Visual Basic).

    IComparer comparer

    The IComparer implementation to use when comparing elements.

    -or-

    nullNothingnullptrunit a null reference(Nothing in Visual Basic) to use the IComparable implementation of each element.

    Returns
    Type Description
    int

    The zero-based index of value in the sorted ArrayList, if value is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Count.

    Clear()

    Removes all elements from the ArrayList.

    Declaration
    public virtual void Clear()

    Clone()

    Creates a shallow copy of the ArrayList.

    Declaration
    public virtual object Clone()
    Returns
    Type Description
    object

    A shallow copy of the ArrayList.

    Contains(object)

    Determines whether an element is in the ArrayList.

    Declaration
    public virtual bool Contains(object value)
    Parameters
    Type Name Description
    object value
    Returns
    Type Description
    bool

    Theobject to locate in the ArrayList.The value can be null.

    CopyTo(Array, int)

    Copies the entire ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array.

    Declaration
    public virtual void CopyTo(Array array, int index)
    Parameters
    Type Name Description
    Array array

    The one-dimensional Array that is the destination of the elements copied from ArrayList. The Array must have zero-based indexing.

    int index

    The zero-based index in array at which copying begins.

    CopyTo(Array)

    Copies the entire ArrayList to a compatible one-dimensional Array, starting at the beginning of the target array.

    Declaration
    public virtual void CopyTo(Array array)
    Parameters
    Type Name Description
    Array array

    The one-dimensional Array that is the destination of the elements copied from ArrayList. The Array must have zero-based indexing.

    GetEnumerator()

    Returns an enumerator for the entire ArrayList.

    Declaration
    public virtual IEnumerator GetEnumerator()
    Returns
    Type Description
    IEnumerator

    An IEnumerator for the entire ArrayList.

    IndexOf(object, int, int)

    Searches for the specified Object and returns the zero-based index of the first occurrence within the range of elements in the ArrayList that starts at the specified index and contains the specified number of elements.

    Declaration
    public virtual int IndexOf(object value, int startIndex, int count)
    Parameters
    Type Name Description
    object value

    The Object to locate in the ArrayList. The value can be null reference (Nothing in Visual Basic).

    int startIndex

    The zero-based starting index of the search. 0 (zero) is valid in an empty list.

    int count

    The number of elements in the section to search.

    Returns
    Type Description
    int

    The zero-based index of the first occurrence of value within the range of elements in the ArrayList that starts at startIndex and contains count number of elements, if found; otherwise, -1.

    IndexOf(object, int)

    Searches for the specified Object and returns the zero-based index of the first occurrence within the range of elements in the ArrayList that extends from the specified index to the last element.

    Declaration
    public virtual int IndexOf(object value, int startIndex)
    Parameters
    Type Name Description
    object value

    The Object to locate in the ArrayList. The value can be null reference (Nothing in Visual Basic).

    int startIndex

    The zero-based starting index of the search. 0 (zero) is valid in an empty list.

    Returns
    Type Description
    int

    The zero-based index of the first occurrence of value within the range of elements in the ArrayList that extends from startIndex to the last element, if found; otherwise, -1.

    IndexOf(object)

    Searches for the specified Object and returns the zero-based index of the first occurrence within the entire ArrayList.

    Declaration
    public virtual int IndexOf(object value)
    Parameters
    Type Name Description
    object value

    The Object to locate in the ArrayList. The value can be null reference (Nothing in Visual Basic).

    Returns
    Type Description
    int

    The zero-based index of the first occurrence of value within the entire ArrayList, if found; otherwise, -1.

    Insert(int, object)

    Inserts an element into the ArrayList at the specified index.

    Declaration
    public virtual void Insert(int index, object value)
    Parameters
    Type Name Description
    int index

    The zero-based index at which

    value

    should be inserted.
    object value

    The object to insert. The value can be null.

    Remove(object)

    Removes the first occurrence of a specific object from the ArrayList.

    Declaration
    public virtual void Remove(object value)
    Parameters
    Type Name Description
    object value

    The object to remove from the ArrayList. The value can be null.

    RemoveAt(int)

    Removes the element at the specified index of the ArrayList.

    Declaration
    public virtual void RemoveAt(int index)
    Parameters
    Type Name Description
    int index

    The zero-based index of the element to remove.

    ToArray()

    Copies the elements of the ArrayList to a new object array.

    Declaration
    public virtual object[] ToArray()
    Returns
    Type Description
    object[]

    An Object array containing copies of the elements of the ArrayList.

    Remarks

    Available only in mscorlib build with support for System.Reflection.

    ToArray(Type)

    Copies the elements of the ArrayList to a new array of the specified element type.

    Declaration
    public virtual Array ToArray(Type type)
    Parameters
    Type Name Description
    Type type

    The element Type of the destination array to create and copy elements to.

    Returns
    Type Description
    Array

    An array of the specified element type containing copies of the elements of the ArrayList.

    Implements

    IList
    ICollection
    IEnumerable
    ICloneable

    Extension Methods

    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    In This Article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX