HashSet<T>.CopyTo 方法

定义

HashSet<T> 集合中的元素复制到数组中。Copies the elements of a HashSet<T> collection to an array.

重载

CopyTo(T[])

HashSet<T> 对象的元素复制到数组中。Copies the elements of a HashSet<T> object to an array.

CopyTo(T[], Int32)

从指定数组索引处开始,将 HashSet<T> 对象的元素复制到数组中。Copies the elements of a HashSet<T> object to an array, starting at the specified array index.

CopyTo(T[], Int32, Int32)

从指定数组索引处开始,将 HashSet<T> 对象的指定数目的元素复制到数组中。Copies the specified number of elements of a HashSet<T> object to an array, starting at the specified array index.

CopyTo(T[])

HashSet<T> 对象的元素复制到数组中。Copies the elements of a HashSet<T> object to an array.

public:
 void CopyTo(cli::array <T> ^ array);
public void CopyTo (T[] array);
member this.CopyTo : 'T[] -> unit
Public Sub CopyTo (array As T())

参数

array
T[]

作为从 HashSet<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.

异常

arraynullarray is null.

注解

此方法的运算复杂度为 O (n),其中 n CountThis method is an O(n) operation, where n is Count.

CopyTo(T[], Int32)

从指定数组索引处开始,将 HashSet<T> 对象的元素复制到数组中。Copies the elements of a HashSet<T> object to an array, starting at the specified array index.

public:
 virtual void CopyTo(cli::array <T> ^ array, int arrayIndex);
public void CopyTo (T[] array, int arrayIndex);
abstract member CopyTo : 'T[] * int -> unit
override this.CopyTo : 'T[] * int -> unit
Public Sub CopyTo (array As T(), arrayIndex As Integer)

参数

array
T[]

作为从 HashSet<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
Int32

array 中从零开始的索引,从此处开始复制。The zero-based index in array at which copying begins.

实现

异常

arraynullarray is null.

arrayIndex 小于 0。arrayIndex is less than 0.

arrayIndex 大于目标 array 的长度。arrayIndex is greater than the length of the destination array.

注解

此方法的运算复杂度为 O (n),其中 n CountThis method is an O(n) operation, where n is Count.

CopyTo(T[], Int32, Int32)

从指定数组索引处开始,将 HashSet<T> 对象的指定数目的元素复制到数组中。Copies the specified number of elements of a HashSet<T> object to an array, starting at the specified array index.

public:
 void CopyTo(cli::array <T> ^ array, int arrayIndex, int count);
public void CopyTo (T[] array, int arrayIndex, int count);
member this.CopyTo : 'T[] * int * int -> unit
Public Sub CopyTo (array As T(), arrayIndex As Integer, count As Integer)

参数

array
T[]

作为从 HashSet<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
Int32

array 中从零开始的索引,从此处开始复制。The zero-based index in array at which copying begins.

count
Int32

要复制到 array 的元素的数目。The number of elements to copy to array.

异常

arraynullarray is null.

arrayIndex 小于 0。arrayIndex is less than 0.

- 或 --or- count 小于 0。count is less than 0.

arrayIndex 大于目标 array 的长度。arrayIndex is greater than the length of the destination array.

- 或 --or- count 大于从 index 到目标 array 末尾的可用空间。count is greater than the available space from the index to the end of the destination array.

注解

此方法的运算复杂度为 O (n),其中 n countThis method is an O(n) operation, where n is count.

适用于