InstanceDataCollectionCollection.Values Property


Gets the instance data values that comprise the collection of instances for the counter.

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

public ICollection Values { get; }

Property Value

Type: System.Collections.ICollection

An ICollection that represents the counter's instances and their associated data values.

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

// Process the InstanceDataCollectionCollection for this category.
PerformanceCounterCategory pcc = new PerformanceCounterCategory(categoryName);
InstanceDataCollectionCollection idColCol = pcc.ReadCategory();

ICollection idColColKeys = idColCol.Keys;
string[] idCCKeysArray = new string[idColColKeys.Count];
idColColKeys.CopyTo(idCCKeysArray, 0);

ICollection idColColValues = idColCol.Values;
InstanceDataCollection[] idCCValuesArray = new InstanceDataCollection[idColColValues.Count];
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.
int index;
for(index=0; index<idCCKeysArray.Length; index++)
    Console.WriteLine("  Next InstanceDataCollectionCollection " +
        "Key is \"{0}\"", idCCKeysArray[index]);

.NET Framework
Available since 1.1
Return to top