다음을 통해 공유


InstanceDataCollectionCollection.CopyTo 메서드

정의

컬렉션의 지정된 인덱스에 InstanceDataCollection 인스턴스의 배열을 복사합니다.

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)

매개 변수

counters
InstanceDataCollection[]

포함된 카운터로 식별되는, 컬렉션에 추가할 InstanceDataCollection 인스턴스의 배열입니다.

index
Int32

새 인스턴스를 추가할 위치입니다.

예제

다음 코드 예제에서는 메서드를 CopyTo 사용하여 를 개체 배열 InstanceDataCollection 로 변환 InstanceDataCollectionCollection 합니다. 배열의 InstanceDataCollection 각 요소는 추가 처리를 위해 함수에 전달됩니다.


// 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

적용 대상