InstanceDataCollection.Values Property

 

Gets the raw counter values that comprise the instance data 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 raw data values.

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

// Display the contents of an InstanceDataCollection.
public static void ProcessInstanceDataCollection(InstanceDataCollection idCol)
{

    ICollection idColKeys = idCol.Keys;
    string[] idColKeysArray = new string[idColKeys.Count];
    idColKeys.CopyTo(idColKeysArray, 0);

    ICollection idColValues = idCol.Values;
    InstanceData[] idColValuesArray = new InstanceData[idColValues.Count];
    idColValues.CopyTo(idColValuesArray, 0);

    Console.WriteLine("  InstanceDataCollection for \"{0}\" " +
        "has {1} elements.", idCol.CounterName, idCol.Count);

    // Display the InstanceDataCollection Keys and Values.
    // The Keys and Values collections have the same number of elements.
    int index;
    for(index=0; index<idColKeysArray.Length; index++)
    {
        Console.WriteLine("    Next InstanceDataCollection " +
            "Key is \"{0}\"", idColKeysArray[index]);
        ProcessInstanceDataObject(idColValuesArray[index]);
    }
}

.NET Framework
Available since 1.1
Return to top
Show: