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 ,其中 nCountThis 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 ,其中 nCountThis 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 ,其中 ncountThis method is an O(n) operation, where n is count.

適用於