共用方式為


InstanceDataCollection.Values 屬性

定義

取得未經處理的計數器值,這些數值構成計數器的執行個體資料。

public:
 property System::Collections::ICollection ^ Values { System::Collections::ICollection ^ get(); };
public System.Collections.ICollection Values { get; }
member this.Values : System.Collections.ICollection
Public ReadOnly Property Values As ICollection

屬性值

ICollection,表示計數器未經處理的資料值。

範例

下列程式代碼範例會使用 ValuesInstanceDataCollection 屬性傳回 物件集合 InstanceData ,而對象會轉換成陣列。 它會使用 Keys 屬性產生實例名稱的陣列。 針對物件陣列 InstanceData 中的每個專案,它會顯示相關聯的實例名稱,並呼叫函式來處理 InstanceData 物件。

// 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]);
    }
}
' Display the contents of an InstanceDataCollection.
Sub ProcessInstanceDataCollection(ByVal idCol As InstanceDataCollection)

    Dim idColKeys As ICollection = idCol.Keys
    Dim idColKeysArray(idColKeys.Count - 1) As String
    idColKeys.CopyTo(idColKeysArray, 0)

    Dim idColValues As ICollection = idCol.Values
    Dim idColValuesArray(idColValues.Count - 1) As InstanceData
    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.
    Dim index As Integer
    For index = 0 To idColKeysArray.Length - 1
        Console.WriteLine("    Next InstanceDataCollection " & _
            "Key is ""{0}""", idColKeysArray(index))
        ProcessInstanceDataObject(idColValuesArray(index))
    Next index
End Sub

適用於