InstanceDataCollection.Values 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取组成计数器实例数据的原始计数器值。
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,它表示计数器的原始数据值。
示例
下面的代码示例使用 Values 的 InstanceDataCollection 属性返回 对象的集合 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