Evidence.CopyTo(Array, Int32) Evidence.CopyTo(Array, Int32) Evidence.CopyTo(Array, Int32) Method

定义

警告

此 API 现已过时。

将证据对象复制到 ArrayCopies evidence objects to an Array.

public:
 virtual void CopyTo(Array ^ array, int index);
[System.Obsolete]
[System.Obsolete("Evidence should not be treated as an ICollection. Please use the GetHostEnumerator and GetAssemblyEnumerator methods rather than using CopyTo.")]
public void CopyTo (Array array, int index);
abstract member CopyTo : Array * int -> unit
override this.CopyTo : Array * int -> unit

参数

array
Array Array Array

要向其复制证据对象的目标数组。The target array to which to copy evidence objects.

index
Int32 Int32 Int32

数组中从零开始的位置,从该位置开始向其复制证据对象。The zero-based position in the array to which to begin copying evidence objects.

实现

异常

index 在目标数组的范围之外。index is outside the range of the target array.

示例

下面的代码示例演示如何使用 CopyTo 方法。The following code example shows the use of the CopyTo method. 此示例是为 Evidence 类提供的更大示例的一部分。This example is part of a larger example provided for the Evidence class.

Console::WriteLine( "\nCopy the evidence to an array using CopyTo, then display the array." );
array<Object^>^evidenceArray = gcnew array<Object^>(myEvidence->Count);
myEvidence->CopyTo( evidenceArray, 0 );
for each (Object^ obj in evidenceArray)
{
   Console::WriteLine(obj->ToString());
}
Console.WriteLine("\nCopy the evidence to an array using CopyTo, then display the array.");
object[] evidenceArray = new object[myEvidence.Count];
myEvidence.CopyTo(evidenceArray, 0);
foreach (object obj in evidenceArray)
{
    Console.WriteLine(obj.ToString());
}
Console.WriteLine(ControlChars.Lf & "Copy the evidence to an array using CopyTo, then display the array.")
Dim evidenceArray(myEvidence.Count - 1) As Object
myEvidence.CopyTo(evidenceArray, 0)
Dim obj As Object
For Each obj In evidenceArray
    Console.WriteLine(obj.ToString())
Next obj

适用于