Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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]);
    ProcessInstanceDataCollection(idCCValuesArray[index]);
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft