InstanceDataCollectionCollection.CopyTo Methode

Definitie

Kopieert een matrix met InstanceDataCollection exemplaren naar de verzameling, op de opgegeven index.

public:
 void CopyTo(cli::array <System::Diagnostics::InstanceDataCollection ^> ^ counters, int index);
public void CopyTo(System.Diagnostics.InstanceDataCollection[] counters, int index);
override this.CopyTo : System.Diagnostics.InstanceDataCollection[] * int -> unit
Public Sub CopyTo (counters As InstanceDataCollection(), index As Integer)

Parameters

counters
InstanceDataCollection[]

Een matrix van InstanceDataCollection exemplaren (geïdentificeerd door de tellers die ze bevatten) om toe te voegen aan de verzameling.

index
Int32

De locatie waar de nieuwe exemplaren moeten worden toegevoegd.

Voorbeelden

In het volgende codevoorbeeld wordt de CopyTo methode gebruikt om een InstanceDataCollectionCollection te converteren naar een matrix met InstanceDataCollection objecten. Elk element van de InstanceDataCollection matrix wordt doorgegeven aan een functie voor verdere verwerking.


// Process the InstanceDataCollectionCollection for this category.
PerformanceCounterCategory pcc = new PerformanceCounterCategory(categoryName);
InstanceDataCollectionCollection idColCol = pcc.ReadCategory();
InstanceDataCollection[] idColArray = new InstanceDataCollection[idColCol.Count];

Console.WriteLine("InstanceDataCollectionCollection for \"{0}\" " +
    "has {1} elements.", categoryName, idColCol.Count);

// Copy and process the InstanceDataCollection array.
idColCol.CopyTo(idColArray, 0);

foreach ( InstanceDataCollection idCol in idColArray )
{
    ProcessInstanceDataCollection(idCol);
}

' Process the InstanceDataCollectionCollection for this category.
Dim pcc As New PerformanceCounterCategory(categoryName)
Dim idColCol As InstanceDataCollectionCollection = pcc.ReadCategory()
Dim idColArray(idColCol.Count - 1) As InstanceDataCollection

Console.WriteLine("InstanceDataCollectionCollection for ""{0}"" " & _
    "has {1} elements.", categoryName, idColCol.Count)

' Copy and process the InstanceDataCollection array.
idColCol.CopyTo(idColArray, 0)

Dim idCol As InstanceDataCollection
For Each idCol In idColArray
    ProcessInstanceDataCollection(idCol)
Next idCol

Van toepassing op