This documentation is archived and is not being maintained.

InstanceDataCollectionCollection.Keys Property

Gets the object and counter registry keys for the objects associated with this instance data collection.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

public ICollection Keys { get; }
/** @property */
public ICollection get_Keys ()

public function get Keys () : ICollection

Property Value

An ICollection that represents a set of object-specific registry keys.

Each software component creates keys for its objects and counters when it is installed and writes counter data while it is executing. You can access this data as you would access any other registry data. However, although you use the registry to collect performance data, the data is not stored in the registry database. Instead, the system collects the data from the appropriate system object managers.

The following code example uses the Keys property of an InstanceDataCollectionCollection to return a collection of counter names, which it converts to an array of String. It generates an array of InstanceDataCollection objects using the Values property. For each element in the array of counter names, it displays the name and calls a function to process the associated InstanceDataCollection.

' Process the InstanceDataCollectionCollection for this category.
Dim pcc As New PerformanceCounterCategory(categoryName)
Dim idColCol As InstanceDataCollectionCollection = pcc.ReadCategory()

Dim idColColKeys As ICollection = idColCol.Keys
Dim idCCKeysArray(idColColKeys.Count - 1) As String
idColColKeys.CopyTo(idCCKeysArray, 0)

Dim idColColValues As ICollection = idColCol.Values
Dim idCCValuesArray(idColColValues.Count - 1) As InstanceDataCollection
idColColValues.CopyTo(idCCValuesArray, 0)

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

' Display the InstanceDataCollectionCollection Keys and Values.
' The Keys and Values collections have the same number of elements.
Dim index As Integer
For index = 0 To idCCKeysArray.Length - 1
    Console.WriteLine("  Next InstanceDataCollectionCollection " & _
        "Key is ""{0}""", idCCKeysArray(index))
Next index

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0