System.Collections.ArrayList Class

public class ArrayList : ICloneable, ICollection, IEnumerable, IList

Base Types

Object
  ArrayList

This type implements IList, ICollection, IEnumerable, and ICloneable.

Assembly

mscorlib

Library

BCL

Summary

Implements a variable-size IList that uses an array of objects to store its elements.

Description

ArrayList implements a variable-size IList that uses an array of objects to store the elements. A ArrayList has a System.Collections.ArrayList.Capacity, which is the allocated length of the internal array. The total number of elements contained by a list is its System.Collections.ArrayList.Count. As elements are added to a list, its capacity is automatically increased as required by reallocating the internal array.

Example

The following example shows how to create, initialize, and display the values of a ArrayList.

using System; 
using System.Collections; 

public class SamplesArrayList { 

  public static void Main() { 

  // Create and initialize a new ArrayList. 
  ArrayList myAL = new ArrayList(); 
  myAL.Add("Hello"); 
  myAL.Add("World"); 
  myAL.Add("!"); 

  // Display the properties and values of the ArrayList. 
  Console.WriteLine( "myAL" ); 
  Console.WriteLine( "Count: {0}", myAL.Count ); 
  Console.WriteLine( "Capacity: {0}", myAL.Capacity ); 
  Console.Write( "Values:" ); 
  PrintValues( myAL ); 
  } 

public static void PrintValues( IEnumerable myList ) { 

  IEnumerator myEnumerator = myList.GetEnumerator(); 
  while ( myEnumerator.MoveNext() ) 
    Console.Write( " {0}", myEnumerator.Current ); 
    Console.WriteLine(); 
  } 
}
The output is

myAL

Count: 3

Capacity: 16

Values: Hello World !

Attributes

DefaultMemberAttribute("Item")

See Also

System.Collections Namespace

Members

ArrayList Constructors

ArrayList() Constructor
ArrayList(int) Constructor
ArrayList(System.Collections.ICollection) Constructor

ArrayList Methods

ArrayList.Adapter Method
ArrayList.Add Method
ArrayList.AddRange Method
ArrayList.BinarySearch(System.Object, System.Collections.IComparer) Method
ArrayList.BinarySearch(System.Object) Method
ArrayList.BinarySearch(int, int, System.Object, System.Collections.IComparer) Method
ArrayList.Clear Method
ArrayList.Clone Method
ArrayList.Contains Method
ArrayList.CopyTo(System.Array, int) Method
ArrayList.CopyTo(int, System.Array, int, int) Method
ArrayList.CopyTo(System.Array) Method
ArrayList.FixedSize Method
ArrayList.GetEnumerator() Method
ArrayList.GetEnumerator(int, int) Method
ArrayList.GetRange Method
ArrayList.IndexOf(System.Object) Method
ArrayList.IndexOf(System.Object, int, int) Method
ArrayList.IndexOf(System.Object, int) Method
ArrayList.Insert Method
ArrayList.InsertRange Method
ArrayList.LastIndexOf(System.Object, int, int) Method
ArrayList.LastIndexOf(System.Object, int) Method
ArrayList.LastIndexOf(System.Object) Method
ArrayList.ReadOnly Method
ArrayList.Remove Method
ArrayList.RemoveAt Method
ArrayList.RemoveRange Method
ArrayList.Repeat Method
ArrayList.Reverse(int, int) Method
ArrayList.Reverse() Method
ArrayList.SetRange Method
ArrayList.Sort(int, int, System.Collections.IComparer) Method
ArrayList.Sort(System.Collections.IComparer) Method
ArrayList.Sort() Method
ArrayList.Synchronized Method
ArrayList.ToArray(System.Type) Method
ArrayList.ToArray() Method
ArrayList.TrimToSize Method

ArrayList Properties

ArrayList.Capacity Property
ArrayList.Count() Property
ArrayList.Count() Property
ArrayList.IsFixedSize() Property
ArrayList.IsFixedSize() Property
ArrayList.IsReadOnly() Property
ArrayList.IsReadOnly() Property
ArrayList.IsSynchronized() Property
ArrayList.IsSynchronized() Property
ArrayList.Item Property
ArrayList.SyncRoot() Property
ArrayList.SyncRoot() Property


ArrayList() Constructor

public ArrayList();

Summary

Constructs and initializes a new instance of the ArrayList class that is empty and has the default initial System.Collections.ArrayList.Capacity .

Description

The default initial System.Collections.ArrayList.Capacity of a ArrayList is 16.

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList(int) Constructor

public ArrayList(int capacity);

Summary

Constructs and initializes a new instance of the ArrayList class that is empty and has the specified initial System.Collections.ArrayList.Capacity .

Parameters

capacity
A Int32 that specifies the number of elements that the new instance is initially capable of storing.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptioncapacity < 0.

Description

If capacity is zero, the System.Collections.ArrayList.Capacity of the current instance is set to 16 when the first element is added.

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList(System.Collections.ICollection) Constructor

public ArrayList(ICollection c);

Summary

Constructs and initializes a new instance of the ArrayList class with the elements from the specified ICollection. The initial System.Collections.ArrayList.Count and System.Collections.ArrayList.Capacity of the new list are both equal to the number of elements in the specified collection.

Parameters

c
The ICollection whose elements are copied to the new list.

Exceptions

Exception TypeCondition
ArgumentNullExceptionc is null .

Description

The elements in the new ArrayList instance are in the same order as contained in c.

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Adapter Method

public static ArrayList Adapter(IList list);

Summary

Creates a ArrayList that is a wrapper for the specified IList.

Parameters

list
The IList to wrap.

Return Value

The ArrayList wrapper for list.

Exceptions

Exception TypeCondition
ArgumentNullExceptionlist is null .

Description

This method returns a ArrayList that contains a reference to the IListlist . Any modifications to the elements in either the returned list or list are reflected in the other.

[Note: The ArrayList class provides generic System.Collections.ArrayList.Reverse, System.Collections.ArrayList.BinarySearch(System.Int32,System.Int32,System.Object,System.Collections.IComparer) and System.Collections.ArrayList.Sort methods. This wrapper provides a means to use those methods on IListlist without implementing the methods for the list. Performing these operations through the wrapper may be less efficient than operations applied directly to the list.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Add Method

public virtual int Add(object value);

Summary

Adds the specified Object to the end of the current instance.

Parameters

value
The Object to be added to the end of the current instance.

Return Value

A Int32 that specifies the index of the current instance at which value has been added.

Exceptions

Exception TypeCondition
NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Behaviors: As described above.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.AddRange Method

public virtual void AddRange(ICollection c);

Summary

Adds the elements of the specified ICollection to the end of the current instance.

Parameters

c
The ICollection whose elements are added to the end of the current instance.

Exceptions

Exception TypeCondition
ArgumentNullExceptionc is null .
NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Behaviors: As described above.]

[Default: If the System.Collections.ArrayList.Count of the current instance plus the size of the collection being added is greater than the System.Collections.ArrayList.Capacity of the current instance, the capacity of the current instance is either doubled or increased to the new System.Collections.ArrayList.Count, whichever is greater. The internal array is reallocated to accommodate the new elements and the existing elements are copied to the new array before the new elements are added.]

[Note: For the default implementation, if the current instance can accommodate the new elements without increasing the System.Collections.ArrayList.Capacity, this method is an O(n) operation, where n is the number of elements to be added. If the capacity needs to be increased to accommodate the new elements, this method becomes an O(n+m) operation, where n is the number of elements to be added and m is System.Collections.ArrayList.Count .]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.BinarySearch(System.Object, System.Collections.IComparer) Method

public virtual int BinarySearch(object value, IComparer comparer);

Summary

Searches the current instance for the specified Object using the specified IComparer implementation.

Parameters

value
The Object for which to search.
comparer
The IComparer implementation to use when comparing elements. Specify null to use the IComparable implementation of each element.

Return Value

A Int32 that specifies the results of the search as follows:

Return ValueDescription
The index of value in the current instance.value was found.
The bitwise complement of the index of the first element that is greater than value.value was not found, and at least one element in the current instance is greater than value.
The bitwise complement of the System.Collections.ArrayList.Count of the current instance.value was not found, and value is greater than all elements in the current instance.
[Note: If value is not found and the current instance is already sorted, the bitwise complement of the return value indicates the index in the current instance where value would be found.]

Exceptions

Exception TypeCondition
ArgumentExceptioncomparer is null , and both value and at least one element in the current instance do not implement the IComparable interface.

-or-

comparer is null , and value is not assignment-compatible with at least one element in the current instance.

Description

[Note: A null reference can be compared with any type; therefore, comparisons with a null reference do not generate exceptions. A null reference evaluates to less than any non-null object, or equal to another null reference, when the two are compared.]

[Behaviors: As described above.]

[Default: This method uses System.Array.BinarySearch(System.Array,System.Object) to search for value.

value is compared to elements in a binary search of the current instance until an element with a value greater than or equal to value is found. If comparer is null , the IComparable implementation of the element being compared -- or of value if the element being compared does not implement the interface -- is used to make the comparison. If value does not implement the IComparable interface and is compared to an element that does not implement the interface either, ArgumentException is thrown. If the current instance is not already sorted, correct results are not guaranteed.

]

[Note: For the default implementation, this method is an O(log2n) operation where n is equal to the System.Collections.ArrayList.Count of the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.BinarySearch(System.Object) Method

public virtual int BinarySearch(object value);

Summary

Searches the current instance for the specified Object.

Parameters

value
The Object for which to search.

Return Value

A Int32 that specifies the results of the search as follows:

Return ValueDescription
The index of value in the current instance.value was found.
The bitwise complement of the index of the first element that is greater than value.value was not found, and at least one element in the current instance is greater than value.
The bitwise complement of the System.Collections.ArrayList.Count of the current instance.value was not found, and value is greater than all elements in the current instance.
[Note: If value is not found and the current instance is already sorted, the bitwise complement of the return value indicates the index in the current instance where value would be found.]

Exceptions

Exception TypeCondition
ArgumentException Both value and at least one element of the current instance do not implement the IComparable interface.

-or-

value is not assignment-compatible with at least one element in the current instance.

Description

[Note: A null reference can be compared with any type; therefore, comparisons with a null reference do not generate exceptions. A null reference evaluates to less than any non-null object, or equal to another null reference, when the two are compared.]

[Behaviors: As described above.]

[Default: This method uses System.Array.BinarySearch(System.Array,System.Object) to search for value.

value is compared to elements in a binary search of the current instance until an element with a value greater than or equal to value is found. The IComparable implementation of the element being compared -- or of value if the element being compared does not implement the interface -- is used to make the comparison. If value does not implement the IComparable interface and is compared to an element that does not implement the interface either, ArgumentException is thrown. If the current instance is not already sorted, correct results are not guaranteed.

]

[Note: For the default implementation, this method is an O(log2n) operation where n is equal to the System.Collections.ArrayList.Count of the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.BinarySearch(int, int, System.Object, System.Collections.IComparer) Method

public virtual int BinarySearch(int index, int count, object value, IComparer comparer);

Summary

Searches the specified range in the current instance for the specified Object using the specified IComparer implementation.

Parameters

index
A Int32 that specifies the index at which searching starts. This value is greater than or equal to zero, and less than the System.Collections.ArrayList.Count of the current instance.

count
A Int32 that specifies the number of elements to search, beginning with index . This value is greater than or equal to zero, and less than or equal to the System.Collections.ArrayList.Count of the current instance minus index.
value
The Object for which to search.
comparer
The IComparer implementation to use when comparing elements. Specify null to use the IComparable implementation of each element.

Return Value

A Int32 that specifies the results of the search as follows:

Return ValueDescription
The index of value in the current instance.value was found.
The bitwise complement of the index of the first element that is greater than value.value was not found, and at least one element in the range of index to index + count in the current instance is greater than value.
The bitwise complement of (index + count)value was not found, and value is greater than all elements in the range of index to index + count in the current instance.
[Note: If value is not found and the current instance is already sorted, the bitwise complement of the return value indicates the index in the current instance where value would be found in the range of index to index + count .]

Exceptions

Exception TypeCondition
ArgumentExceptionSystem.Collections.ArrayList.Count of the current instance - index < count.

-or-

comparer is null , and both value and at least one element of the current instance do not implement the IComparable interface.

-or-

comparer is null , and value is not assignment-compatible with at least one element in the current instance.

ArgumentOutOfRangeExceptionindex < 0.

-or-

count < 0.

Description

[Note: A null reference can be compared with any type; therefore, comparisons with a null reference do not generate exceptions. A null reference evaluates to less than any non-null object, or equal to another null reference, when the two are compared.]

[Behaviors: As described above.]

[Default: This method uses System.Array.BinarySearch(System.Array,System.Object) to search for value .

value is compared to elements in a binary search of the range of index to index + count in the current instance until an element with a value greater than or equal to value is found or the end of the range is reached. If comparer is null , the IComparable implementation of the element being compared -- or of value if the element being compared does not implement the interface -- is used to make the comparison. If value does not implement the IComparable interface and is compared to an element that does not implement the interface either, ArgumentException is thrown. If the current instance is not already sorted, correct results are not guaranteed.

]

[Note: For the default implementation, this method is an O(log2count) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Clear Method

public virtual void Clear();

Summary

Sets the elements in the current instance to zero, false , or null , depending upon the element type.

Exceptions

Exception TypeCondition
NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Note: This method is implemented to support the IList interface. ]

[Behaviors: Reference-type elements are set to null . Value-type elements are set to zero, except for Boolean elements, which are set to false . ]

[Default: This method uses System.Array.Clear(System.Array,System.Int32,System.Int32) to reset the values of the current instance. System.Collections.ArrayList.Count is set to zero. System.Collections.ArrayList.Capacity is not changed. ]

[Usage: To reset the System.Collections.ArrayList.Capacity of the current instance, call System.Collections.ArrayList.TrimToSize or set the System.Collections.ArrayList.Capacity property directly. ]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Clone Method

public virtual object Clone();

Summary

Returns a Object that is a copy of the current instance.

Return Value

A Object that is a copy of the current instance.

Description

[Note: This method is implemented to support the ICloneable interface.]

[Behaviors: As described above.]

[Default: This method uses System.Array.Copy(System.Array,System.Array,System.Int32) to clone the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Contains Method

public virtual bool Contains(object item);

Summary

Determines whether the specified Object is contained in the current instance.

Parameters

item
The Object to locate in the current instance.

Return Value

true if item is contained in the current instance; otherwise, false .

Description

[Note: This method is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: This method determines equality by calling the System.Object.Equals(System.Object) implementation of the type of item.]

[Note: For the default implementation, this method is an O(n) operation where n is equal to the System.Collections.ArrayList.Count of the current instance. If the current instance is sorted, it is more efficient to call System.Collections.ArrayList.BinarySearch(System.Int32,System.Int32,System.Object,System.Collections.IComparer) method.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.CopyTo(System.Array, int) Method

public virtual void CopyTo(Array array, int arrayIndex);

Summary

Copies the elements from the current instance to the specified Array , starting at the specified index of the array.

Parameters

array
The one-dimensional Array that is the destination of the elements copied from the current instance. The System.Array.Length of this array is greater than or equal to the sum of arrayIndex and the System.Collections.ArrayList.Count of the current instance.
arrayIndex
A Int32 that specifies the first index of array to which the elements of the current instance are copied. This value is greater than or equal to zero, and less than array.Length.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
ArgumentOutOfRangeExceptionarrayIndex < 0.
ArgumentExceptionarray has more than one dimension.

-or-

arrayIndex >= array.Length.

-or-

arrayIndex + System.Collections.ArrayList.Count of the current instance > array.Length.

InvalidCastExceptionAt least one element in the current instance is not assignment-compatible with the type of array.

Description

[Note: This method is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: This method uses System.Array.Copy(System.Array,System.Array,System.Int32) to copy the current instance to array.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.CopyTo(int, System.Array, int, int) Method

public virtual void CopyTo(int index, Array array, int arrayIndex, int count);

Summary

Copies the specified range of elements from the current instance to the specified Array, starting at the specified index of the array.

Parameters

index
A Int32 that specifies the index in the current instance at which copying begins. This value is greater than or equal to 0, and less than the System.Collections.ArrayList.Count of the current instance.
array
The one-dimensional Array that is the destination of the elements copied from the current instance.
arrayIndex
A Int32 that specifies the first index of array to which the elements of the current instance are copied. This value is greater than or equal to zero, and less than array.Length minus count.
count
A Int32 that specifies the number of elements to copy. This value is greater than or equal to 0, and less than both the System.Collections.ArrayList.Count of the current instance minus index and array.Length minus arrayIndex.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
ArgumentOutOfRangeExceptionindex < 0.

-or-

arrayIndex < 0.

-or-

count < 0.

ArgumentExceptionarray has more than one dimension.

-or-

index >= System.Collections.ArrayList.Count of the current instance .

-or-

count >= System.Collections.ArrayList.Count of the current instance - index.

-or-

count >= array.Length - arrayIndex.

InvalidCastExceptionAt least one element of the current instance is not assignment-compatible with the type of array.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.Copy(System.Array,System.Array,System.Int32) to copy the current instance to array.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.CopyTo(System.Array) Method

public virtual void CopyTo(Array array);

Summary

Copies the elements from the current instance to the specified Array.

Parameters

array
The one-dimensional Array that is the destination of the elements copied from the current instance. The System.Array.Length of this array is greater than or equal to the System.Collections.ArrayList.Count of the current instance.

Exceptions

Exception TypeCondition
ArgumentNullExceptionarray is null .
ArgumentExceptionarray has more than one dimension.

-or-

System.Collections.ArrayList.Count of the current instance > array.Length.

InvalidCastExceptionAt least one element in the current instance is not assignment-compatible with the type of array.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.Copy(System.Array,System.Array,System.Int32) to copy the current instance to array.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.FixedSize Method

public static ArrayList FixedSize(ArrayList list);

Summary

Returns a ArrayList wrapper with a fixed size.

Parameters

list
The ArrayList to wrap.

Return Value

A ArrayList wrapper with a fixed size.

Exceptions

Exception TypeCondition
ArgumentNullExceptionlist is null .

Description

This method returns a fixed-size ArrayList that contains a reference to list. Operations that attempt add to or delete from this new list will throw NotSupportedException. Any modifications of the elements in either the returned list or list will be reflected in the other.

[Note: The System.Collections.ArrayList.IsFixedSize property of the new list is true . Every other property value of the new list references the same property value of list.

By performing operations on the new list, this wrapper can be used to prevent additions to and deletions from the ArrayListlist. The elements of the list can still be modified by operations on the returned list.

]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.GetEnumerator() Method

public virtual IEnumerator GetEnumerator();

Summary

Returns a IEnumerator for the current instance.

Return Value

A IEnumerator for the current instance.

Description

If the elements of the current instance are modified while an enumeration is in progress, a call to System.Collections.IEnumerator.MoveNext or System.Collections.IEnumerator.Current throws InvalidOperationException .

[Note: For detailed information regarding the use of an enumerator, see IEnumerator.

This property is implemented to support the IList interface.

]

[Behaviors: As described above.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.GetEnumerator(int, int) Method

public virtual IEnumerator GetEnumerator(int index, int count);

Summary

Returns a IEnumerator for the specified section of the current instance.

Parameters

index
A Int32 that specifies the index of the current instance before which the enumerator is initially placed. This value is greater than or equal to 0, and less than the System.Collections.ArrayList.Count of the current instance.
count
A Int32 that specifies the number of elements, beginning with index , in the current instance over which the enumerator can iterate. This value if greater than or equal to 0, and less than or equal to the System.Collections.ArrayList.Count of the current instance minus index .

Return Value

A IEnumerator that can iterate over the range of index to index + count in the current instance.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

count < 0.

ArgumentExceptionindex + count > System.Collections.ArrayList.Count of the current instance - index.

Description

The enumerator only enumerates over the range of the current instance from index to index + count. If the elements of the current instance are modified while an enumeration is in progress, a call to System.Collections.IEnumerator.MoveNext or System.Collections.IEnumerator.Current will throw InvalidOperationException .

[Note: For detailed information regarding the use of an enumerator, see IEnumerator.]

[Behaviors: As described above.]

[Default: The enumerator is initially placed just before the element at position index in the current instance. A call to System.Collections.IEnumerator.Reset returns the enumerator to this position.

If the enumerator is positioned over an element in the range of index -1 to index + count, and the elements of the current instance have not been modified while the enumeration was in progress, a call to System.Collections.IEnumerator.MoveNext either returns true and advances the enumerator one element in the current instance, or returns false and leaves the enumerator in its current position.

]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.GetRange Method

public virtual ArrayList GetRange(int index, int count);

Summary

Returns a ArrayList that represents the specified range of the current instance.

Parameters

index
A Int32 that specifies the zero-based index in the current instance at which the range starts. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus count , inclusive.
count
A Int32 that specifies the number of elements in the range. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus index , inclusive.

Return Value

A ArrayList that represents the range in the current instance from index to index + count.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

count < 0.

ArgumentExceptionSystem.Collections.ArrayList.Count of the current instance - index < count.

Description

[Behaviors: As described above.]

[Default: This method does not create copies of the elements: the new ArrayList instance is a view window into the source list. Therefore, all subsequent changes to the source list must be done through this view window ArrayList . If changes are made directly to the source list, the view window list is invalidated and any operations on it throw InvalidOperationException .]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IndexOf(System.Object) Method

public virtual int IndexOf(object value);

Summary

Searches the current instance, returning the index of the first occurrence of the specified Object.

Parameters

value
The Object to locate in current instance.

Return Value

A Int32 that specifies the index of the first occurrence of value in the current instance, if found; otherwise, -1.

[Note: This provides the caller with a standard code for a failed search.]

Description

[Note: This method is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: This method uses System.Array.IndexOf(System.Array,System.Object) to search the current instance for value .]

[Note: For the default implementation, this method performs a linear search. On average, this is an O(n/2) operation, where n is count. The longest search is an O(n) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IndexOf(System.Object, int, int) Method

public virtual int IndexOf(object value, int startIndex, int count);

Summary

Searches the current instance, returning the index of the first occurrence of the specified Object in the specified range.

Parameters

value
The Object to locate in current instance.
startIndex
A Int32 that specifies the index at which to begin searching. This value is less than or equal to zero, and greater than the System.Collections.ArrayList.Count of the current instance.
count
A Int32 that specifies the number of elements to search. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus startIndex , inclusive.

Return Value

A Int32 that specifies the index of the first occurrence of value in the current instance, within the range startIndex to startIndex + count , if found; otherwise, -1.

[Note: This provides the caller with a standard code for a failed search.]

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionstartIndex&gt;= System.Collections.ArrayList.Count of the current instance.

-or-

count < 0.

-or-

count >System.Collections.ArrayList.Count of the current instance - startIndex.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.IndexOf(System.Array,System.Object) to search the current instance for value.]

[Note: For the default implementation, this method performs a linear search. On average, this is an O(n/2) operation, where n is count. The longest search is an O(n) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IndexOf(System.Object, int) Method

public virtual int IndexOf(object value, int startIndex);

Summary

Searches the current instance, returning the index of the first occurrence of the specified Object in the specified range.

Parameters

value
The Object to locate in current instance.
startIndex
A Int32 that specifies the index at which searching begins. This value is between 0 and the System.Collections.ArrayList.Count of the current instance, inclusive.

Return Value

A Int32 that specifies the index of the first occurrence of value in the current instance, if found within the range startIndex to the end of the current instance; otherwise, -1.

[Note: This provides the caller with a standard code for a failed search.]

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionstartIndex < 0.

-or-

startIndex > System.Collections.ArrayList.Count of the current instance.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.IndexOf(System.Array,System.Object) to search the current instance for value.]

[Note: For the default implementation, this method performs a linear search. On average, this is an O(n/2) operation, where n is count. The longest search is an O(n) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Insert Method

public virtual void Insert(int index, object value);

Summary

Inserts the specified Object into the current instance at the specified index.

Parameters

index
A Int32 that specifies the index in the current instance at which value is inserted. This value is between 0 and the System.Collections.ArrayList.Count of the current instance, inclusive.
value
The Object to insert.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

index > System.Collections.ArrayList.Count of the current instance.

NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Note: This method is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: If the System.Collections.ArrayList.Count of the current instance is equal to the System.Collections.ArrayList.Capacity of the current instance, the capacity of the list is doubled by automatically reallocating the internal array before the new element is inserted. If index is equal to the System.Collections.ArrayList.Count of the current instance, value is added to the end of the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.InsertRange Method

public virtual void InsertRange(int index, ICollection c);

Summary

Inserts the elements of the specified ICollection at the specified index of the current instance.

Parameters

index
A Int32 that specifies the index in the current instance at which the new elements are inserted. This value is between 0 and the System.Collections.ArrayList.Count of the current instance, inclusive.
c
The ICollection whose elements are inserted into the current instance.

Exceptions

Exception TypeCondition
ArgumentNullExceptionc is null .
ArgumentOutOfRangeExceptionindex < 0.

index > System.Collections.ArrayList.Count of the current instance.

NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Behaviors: As described above.]

[Default: If the System.Collections.ArrayList.Count of the current instance plus the size of ICollectionc is greater than the System.Collections.ArrayList.Capacity of the current instance, the capacity of the current instance is either doubled or increased to the new count, whichever yields a greater capacity. The internal array is reallocated to accommodate the new elements. If index is equal to the System.Collections.ArrayList.Count of the current instance, the elements of c are added to the end of the current instance.

The order of the elements in the ICollectionc is preserved in the current instance.

]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.LastIndexOf(System.Object, int, int) Method

public virtual int LastIndexOf(object value, int startIndex, int count);

Summary

Searches the current instance, returning the index of the last occurrence of the specified Object in the specified range.

Parameters

value
The Object to locate in the current instance.
startIndex
A Int32 that specifies the index at which searching starts.
count
A Int32 that specifies the number of elements to search, beginning with startIndex .

Return Value

A Int32 that specifies the index of the last occurrence of value in the current instance, within the range startIndex + count through startIndex, if found; otherwise, -1.

[Note: This provides the caller with a standard code for a failed search.]

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionstartIndex < 0.

-or-

count < 0.

-or-

startIndex >= System.Collections.ArrayList.Count of the current instance.

-or-

count >= System.Collections.ArrayList.Count of the current instance.

-or-

count >= startIndex.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.LastIndexOf(System.Array,System.Object) to search the current instance for value.]

[Note: For the default implementation, this method performs a linear search. On average, this is an O(count/2) operation. The longest search is an O(count) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.LastIndexOf(System.Object, int) Method

public virtual int LastIndexOf(object value, int startIndex);

Summary

Searches the current instance, returning the index of the last occurrence of the specified Object in the specified range of the current instance.

Parameters

value
The Object to locate in the current instance.
startIndex
A Int32 that specifies the index at which searching starts. This value is between 0 and the System.Collections.ArrayList.Count of the current instance, inclusive.

Return Value

A Int32 that specifies the index of the last occurrence of value in the range of startIndex through the first element of the current instance, if found; otherwise, -1.

[Note: This provides the caller with a standard code for a failed search.]

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionstartIndex < 0.

-or-

startIndex >= System.Collections.ArrayList.Count of the current instance.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.LastIndexOf(System.Array,System.Object) to search the current instance for value.]

[Note: For the default implementation, this method performs a linear search. On average, this is an O(count/2) operation. The longest search is an O(count) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.LastIndexOf(System.Object) Method

public virtual int LastIndexOf(object value);

Summary

Searches the current instance, returning the index of the last occurrence of the specified Object.

Parameters

value
The Object to locate in the current instance.

Return Value

A Int32 that specifies the index of the last occurrence of value in the current instance, if found; otherwise, -1.

[Note: This provides the caller with a standard code for a failed search.]

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.LastIndexOf(System.Array,System.Object) to search the current instance for value.]

[Note: For the default implementation, this method performs a linear search. On average, this is an O(n/2) operation, where n is System.Collections.ArrayList.Count of the current instance. The longest search is an O(n) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.ReadOnly Method

public static ArrayList ReadOnly(ArrayList list);

Summary

Returns a read-only ArrayList wrapper.

Parameters

list
The ArrayList to wrap.

Return Value

A read-only ArrayList wrapper around list.

Exceptions

Exception TypeCondition
ArgumentNullExceptionlist is null .

Description

This method returns a read-only ArrayList that contains a reference to list. Operations that attempt add to, delete from, or modify the elements of this new list will throw NotSupportedException. Any modifications of the elements list will be reflected in the new list.

[Note: The System.Collections.ArrayList.IsReadOnly property of the new list is true . Every other property value of the new list references the same property value of list.

By performing operations on the new list, this wrapper can be used to prevent additions to, deletions from, and modifications of the ArrayListlist.

]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Remove Method

public virtual void Remove(object obj);

Summary

Removes the first occurrence of the specified Object from the current instance.

Parameters

obj
The Object to remove from the current instance.

Exceptions

Exception TypeCondition
NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Note: This method is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: This method determines equality by calling System.Object.Equals(System.Object).

If and only if obj is found in the current instance, obj is removed from the current instance, the rest of the elements are shifted down to fill the position vacated by obj, the System.Collections.ArrayList.Count of the current instance is decreased by one, and the position that was previously the last element in the current instance is set to null . If obj is not found in the current instance, the current instance remains unchanged.

]

[Note: For the default implementation, this method performs a linear search. On average, this is an O(n/2) operation, where n is System.Collections.ArrayList.Count of the current instance. The longest search is an O(n) operation.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.RemoveAt Method

public virtual void RemoveAt(int index);

Summary

Removes the element at the specified index from the current instance.

Parameters

index
A Int32 that specifies the zero-based index of the element to remove from the current instance. This value is between 0 and the System.Collections.ArrayList.Count of the current instance, inclusive.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

index >= System.Collections.ArrayList.Count of the current instance.

NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Note: This method is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: The element at position index is removed from the current instance, the rest of the elements are shifted down to fill the position vacated by that element, the System.Collections.ArrayList.Count of the current instance is decreased by one, and the position that was previously the last element in the current instance is set to null .]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.RemoveRange Method

public virtual void RemoveRange(int index, int count);

Summary

Removes the specified range of elements from the current instance.

Parameters

index
A Int32 that specifies the zero-based index of the first element of the range of elements in the current instance to remove. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus count , inclusive.
count
A Int32 that specifies the number of elements to remove. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus index , inclusive.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

count < 0.

ArgumentExceptionSystem.Collections.ArrayList.Count of the current instance - index < count.
NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Behaviors: As described above.]

[Default: The elements in the range of index to index + count are removed from the current instance, the rest of the elements are shifted down to fill the position vacated by those elements, the System.Collections.ArrayList.Count of the current instance is decreased by count, and the count positions that were previously the last elements in the current instance are set to null .]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Repeat Method

public static ArrayList Repeat(object value, int count);

Summary

Returns a new ArrayList whose elements are copies of the specified Object.

Parameters

value
The Object used to initialize the new ArrayList instance.

count
A Int32 that specifies the number of times value is copied into the new ArrayList instance.

Return Value

A new ArrayList with count number of elements, all of which are copies of value.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptioncount < 0.

Description

If count is less than the default initial capacity, 16, the System.Collections.ArrayList.Capacity of the new ArrayList instance is set to the default initial capacity. Else, the capacity is set to count . The System.Collections.ArrayList.Count of the new instance is set to count.

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Reverse(int, int) Method

public virtual void Reverse(int index, int count);

Summary

Reverses the sequence of the elements in the specified range of the current instance.

Parameters

index
A Int32 that specifies the zero-based index in the current instance at which reversing starts. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus count , inclusive.
count
A Int32 that specifies the number of elements to reverse. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus index , inclusive.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

count < 0.

ArgumentExceptionSystem.Collections.ArrayList.Count of the current instance - index < count.

NotSupportedExceptionThe current instance is read-only.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.Reverse(System.Array) to modify the ordering of the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Reverse() Method

public virtual void Reverse();

Summary

Reverses the sequence of the elements in the current instance.

Exceptions

Exception TypeCondition
NotSupportedExceptionThe current instance is read-only.

Description

[Behaviors: As described above.]

[Default: This method uses System.Array.Reverse(System.Array) to modify the ordering of the elements in the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.SetRange Method

public virtual void SetRange(int index, ICollection c);

Summary

Copies the elements of the specified ICollection to a range in the current instance.

Parameters

index
A Int32 that specifies the zero-based index in the current instance at which to start copying the elements of c. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus c.Count, inclusive.
c
The ICollection whose elements to copy to the current instance.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

System.Collections.ArrayList.Count of the current instance - index < c.Count.

ArgumentNullExceptionc is null .
NotSupportedExceptionThe current instance is read-only.

Description

[Behaviors: As described above.]

[Default: This method uses the System.Collections.ICollection.CopyTo(System.Array,System.Int32) implementation of ICollectionc.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Sort(int, int, System.Collections.IComparer) Method

public virtual void Sort(int index, int count, IComparer comparer);

Summary

Sorts the elements in the specified range of the current instance using the specified IComparer implementation.

Parameters

index
A Int32 that specifies the zero-based index at which sorting starts. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus count , inclusive.
count
A Int32 that specifies the number of elements to sort. This value is between 0 and the System.Collections.ArrayList.Count of the current instance minus index , inclusive.
comparer
The IComparer implementation to use when comparing elements. Specify null to use the IComparable implementation of each element in the current instance.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

count < 0.

ArgumentExceptionSystem.Collections.ArrayList.Count of the current instance - index < count.

InvalidCastExceptioncomparer is null , and one or more elements in the current instance do not implement the IComparable interface.
NotSupportedExceptionThe current instance is read-only.

Description

[Behaviors: As described above.]

[Default: If comparer is null , the IComparable implementation of each element in the current instance is used to make the sorting comparisons. If the sort is not successfully completed, the results are unspecified.]

[Note: For the default implementation, this method uses System.Array.Sort(System.Array), which uses the Quicksort algorithm. This is an O(n log2n) operation, where n is the number of elements to sort.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Sort(System.Collections.IComparer) Method

public virtual void Sort(IComparer comparer);

Summary

Sorts the elements of current instance using the specified IComparer.

Parameters

comparer
The IComparer implementation to use when comparing elements. Specify null to use the IComparable implementation of each element in the current instance.

Exceptions

Exception TypeCondition
InvalidCastExceptioncomparer is null , and one or more elements in the current instance do not implement the IComparable interface.
NotSupportedExceptionThe current instance is read-only.

Description

[Behaviors: As described above.]

[Default: If comparer is null , the IComparable implementation of each element in the current instance is used to make the sorting comparisons. If the sort is not successfully completed, the results are unspecified.]

[Note: For the default implementation, this method uses System.Array.Sort(System.Array), which uses the Quicksort algorithm. This is an O(n log2n) operation, where n is the number of elements to sort.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Sort() Method

public virtual void Sort();

Summary

Sorts the elements of the current instance.

Exceptions

Exception TypeCondition
InvalidCastExceptionOne or more elements in the current instance do not implement the IComparable interface.
NotSupportedExceptionThe current instance read-only.

Description

[Behaviors: As described above.]

[Default: The IComparable implementation of each element in the current instance is used to make the sorting comparisons. If the sort is not successfully completed, the results are unspecified.]

[Note: For the default implementation, this method uses System.Array.Sort(System.Array), which uses the Quicksort algorithm. This is an O(n log2n) operation, where n is the number of elements to sort.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Synchronized Method

public static ArrayList Synchronized(ArrayList list);

Summary

Returns a ArrayList wrapper around the specified ArrayList that is synchronized (thread-safe).

Parameters

list
The ArrayList to synchronize.

Return Value

A ArrayList wrapper that is synchronized (thread-safe).

Exceptions

Exception TypeCondition
ArgumentNullExceptionlist is null .

Description

This method returns a thread-safe ArrayList that contains a reference to list. Any modifications of the elements in either the returned list or list will be reflected in the other.

[Note: The System.Collections.ArrayList.IsSynchronized property of the new list is true . Every other property value of the new list references the same property value of list.

By performing operations on the new list, this wrapper can be used to guarantee thread-safe access to the ArrayListlist.

]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.ToArray(System.Type) Method

public virtual Array ToArray(Type type);

Summary

Copies the elements of the current instance to a new array of the specified Type.

Parameters

type
The Type of the Array to create and copy the elements of the current instance.

Return Value

An array of Typetype containing copies of the elements of the current instance.

Exceptions

Exception TypeCondition
ArgumentNullExceptiontype is null .
InvalidCastExceptionAt least one element of the current instance cannot be cast to the Typetype.

Description

[Behaviors: As described above.]

[Default: The elements are copied using System.Array.Copy(System.Array,System.Array,System.Int32).]

[Note: For the default implementation, this method is an O(n) operation, where n is the System.Collections.ArrayList.Count of the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.ToArray() Method

public virtual object[] ToArray();

Summary

Copies the elements of the current instance to a new Object array.

Return Value

A Object array containing copies of the elements of the current instance.

Description

[Behaviors: As described above.]

[Default: The elements are copied using System.Array.Copy(System.Array,System.Array,System.Int32).]

[Note: For the default implementation, this method is an O(n) operation, where n is the System.Collections.ArrayList.Count of the current instance.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.TrimToSize Method

public virtual void TrimToSize();

Summary

Sets the System.Collections.ArrayList.Capacity of the current instance to the System.Collections.ArrayList.Count of the current instance.

Exceptions

Exception TypeCondition
NotSupportedExceptionThe current instance is read-only or has a fixed size.

Description

[Note: This method can be used to minimize the memory overhead of the current instance if no new elements will be added to it.

To completely clear all elements from the current instance, call the System.Collections.ArrayList.Clear method before calling System.Collections.ArrayList.TrimToSize.

]

[Behaviors: As described above.]

[Default: If the System.Collections.ArrayList.Count of the current instance is zero, the System.Collections.ArrayList.Capacity of the current instance is set to the default initial capacity of 16.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Capacity Property

public virtual int Capacity { get; set; }

Summary

Gets or sets the number of elements that the current instance is capable of storing.

Property Value

A Int32 that specifies the number of elements that the current instance is capable of storing.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionSystem.Collections.ArrayList.Capacity is set to a value that is less than the System.Collections.ArrayList.Count of the current instance.

Description

[Note: The System.Collections.ArrayList.Capacity of a ArrayList is the size of the internal array used to hold the elements of that list. When it is set, the internal array is reallocated to the specified value.]

[Behaviors: As described above.]

[Default: If an attempt is made to set System.Collections.ArrayList.Capacity to a value less or equal to 0, it is set to the default capacity of 16.

If the System.Collections.ArrayList.Count of the current instance exceeds the System.Collections.ArrayList.Capacity of the current instance while adding elements to the current instance, the capacity of the list is doubled by automatically reallocating the internal array before copying the old elements and adding the new elements.

]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Count() Property

int ICollection.Count { get; }

Summary

Implemented to support the ICollection interface. [Note: For more information, see System.Collections.ICollection.Count.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Count() Property

public virtual int Count { get; }

Summary

Gets the number of elements contained in the current instance.

Property Value

A Int32 that specifies the number of elements contained in the current instance.

Description

This property is read-only.

System.Collections.ArrayList.Count is the number of elements that are contained by the ArrayList. The count of a list is always less than or equal to System.Collections.ArrayList.Capacity of that list.

[Note: This property is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: If the System.Collections.ArrayList.Count exceeds the System.Collections.ArrayList.Capacity of the current instance while adding elements to the current instance, the capacity of the list is doubled by automatically reallocating the internal array before copying the old elements and adding the new elements.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IsFixedSize() Property

bool IList.IsFixedSize { get; }

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.IsFixedSize.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IsFixedSize() Property

public virtual bool IsFixedSize { get; }

Summary

Gets a Boolean indicating whether the System.Collections.ArrayList.Capacity of the current instance cannot be changed.

Property Value

true if the System.Collections.ArrayList.Capacity of the current instance cannot be changed; otherwise, false .

Description

This property is read-only.

[Note: Elements cannot be added or removed from a ArrayList with a fixed size, while existing elements can be modified.

This property is implemented to support the IList interface.

]

[Behaviors: As described above.]

[Default: The default value for this property is false .]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IsReadOnly() Property

bool IList.IsReadOnly { get; }

Summary

Implemented to support the IList interface. [Note: For more information, see System.Collections.IList.IsReadOnly.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IsReadOnly() Property

public virtual bool IsReadOnly { get; }

Summary

Gets a value indicating whether the current instance is read-only.

Property Value

true if the current instance is read-only; otherwise, false .

Description

This property is read-only.

[Note: The elements of a ArrayList that is read-only cannot be modified, nor can elements be added to or removed from that list.

This property is implemented to support the IList interface.

]

[Behaviors: As described above.]

[Default: The default value of this property is false .]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IsSynchronized() Property

bool ICollection.IsSynchronized { get; }

Summary

Implemented to support the ICollection interface. [Note: For more information, see System.Collections.ICollection.IsSynchronized.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.IsSynchronized() Property

public virtual bool IsSynchronized { get; }

Summary

Gets a value indicating whether access to the current instance is synchronized (thread-safe).

Property Value

true if access to the current instance is synchronized (thread-safe); otherwise, false .

Description

This property is read-only.

To guarantee the thread safety of the ArrayList, all operations must be done through the wrapper returned by the System.Collections.ArrayList.Synchronized(System.Collections.IList) method.

[Note: This property is implemented to support the IList interface.]

[Behaviors: As described above.]

[Default: The default value of this property is false .]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.Item Property

public virtual object this[int index] { get; set; }

Summary

Gets or sets the element at the specified index of the current instance.

Parameters

index
A Int32 that specifies the zero-based index of the element in the current instance to get or set. This value is greater than or equal to 0, and less than the System.Collections.ArrayList.Count of the current instance.

Property Value

The element at the specified index of the current instance.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionindex < 0.

-or-

index >= System.Collections.ArrayList.Count of the current instance.

Description

[Note: This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index] .

This property is implemented to support the IList interface.

]

[Behaviors: As described above.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.SyncRoot() Property

object ICollection.SyncRoot { get; }

Summary

Implemented to support the ICollection interface. [Note: For more information, see System.Collections.ICollection.SyncRoot.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace

ArrayList.SyncRoot() Property

public virtual object SyncRoot { get; }

Summary

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

Property Value

A Object that can be used to synchronize access to the current instance.

Description

This property is read-only.

Program code must perform synchronized operations on the System.Collections.ArrayList.SyncRoot of the current instance, not directly on the current instance. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the current instance.

[Behaviors: As described above.]

[Default: This method returns a reference to the current instance.]

[Note: This property is implemented to support the IList interface.]

See Also

System.Collections.ArrayList Class, System.Collections Namespace