InstanceDataCollection.CopyTo(InstanceData[], Int32) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Kopierar objekten i samlingen till den angivna endimensionella matrisen vid det angivna indexet.
public:
void CopyTo(cli::array <System::Diagnostics::InstanceData ^> ^ instances, int index);
public void CopyTo(System.Diagnostics.InstanceData[] instances, int index);
override this.CopyTo : System.Diagnostics.InstanceData[] * int -> unit
Public Sub CopyTo (instances As InstanceData(), index As Integer)
Parametrar
- instances
- InstanceData[]
Den endimensionella Array som är målet för de värden som kopieras från samlingen.
- index
- Int32
Det nollbaserade indexvärde där de nya instanserna ska läggas till.
Exempel
I följande kodexempel används CopyTo metoden för att konvertera en InstanceDataCollection till en matris med InstanceData objekt. Värdena för InstanceName egenskaperna och Sample för varje element i matrisen skickas till en funktion för vidare bearbetning.
// Display the contents of an InstanceDataCollection.
public static void ProcessInstanceDataCollection(InstanceDataCollection idCol)
{
InstanceData[] instDataArray = new InstanceData[idCol.Count];
Console.WriteLine(" InstanceDataCollection for \"{0}\" " +
"has {1} elements.", idCol.CounterName, idCol.Count);
// Copy and process the InstanceData array.
idCol.CopyTo(instDataArray, 0);
int idX;
for(idX=0; idX<instDataArray.Length; idX++)
{
ProcessInstanceDataObject(instDataArray[idX].InstanceName, instDataArray[idX].Sample);
}
}
' Display the contents of an InstanceDataCollection.
Sub ProcessInstanceDataCollection(ByVal idCol As InstanceDataCollection)
Dim instDataArray(idCol.Count - 1) As InstanceData
Console.WriteLine(" InstanceDataCollection for ""{0}"" " & _
"has {1} elements.", idCol.CounterName, idCol.Count)
' Copy and process the InstanceData array.
idCol.CopyTo(instDataArray, 0)
Dim idX As Integer
For idX = 0 To instDataArray.Length - 1
ProcessInstanceDataObject(instDataArray(idX).InstanceName, _
instDataArray(idX).Sample)
Next idX
End Sub