HashSet<T>.CopyTo Method (array<T[], Int32, Int32)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Copies the specified number of elements of a HashSet<T> object to an array, starting at the specified array index.

Namespace:  System.Collections.Generic
Assembly:  System.Core (in System.Core.dll)

Syntax

'Declaration
Public Sub CopyTo ( _
    array As T(), _
    arrayIndex As Integer, _
    count As Integer _
)
public void CopyTo(
    T[] array,
    int arrayIndex,
    int count
)

Parameters

  • array
    Type: array<T[]
    The one-dimensional array that is the destination of the elements copied from the HashSet<T> object. The array must have zero-based indexing.
  • arrayIndex
    Type: System.Int32
    The zero-based index in array at which copying begins.
  • count
    Type: System.Int32
    The number of elements to copy to array.

Exceptions

Exception Condition
ArgumentNullException

array is nulla null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

arrayIndex is less than 0.

-or-

count is less than 0.

ArgumentException

arrayIndex is greater than the length of the destination array.

-or-

count is greater than the available space from the index to the end of the destination array.

Remarks

This method is an O(n) operation, where n is count.

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.