PropertyDataCollection.PropertyDataEnumerator 類別

定義

表示 PropertyData 中的 PropertyDataCollection 物件列舉值。

public: ref class PropertyDataCollection::PropertyDataEnumerator : System::Collections::IEnumerator
public class PropertyDataCollection.PropertyDataEnumerator : System.Collections.IEnumerator
type PropertyDataCollection.PropertyDataEnumerator = class
    interface IEnumerator
Public Class PropertyDataCollection.PropertyDataEnumerator
Implements IEnumerator
繼承
PropertyDataCollection.PropertyDataEnumerator
實作

範例

下列範例會透過 Win32_LogicalDisk 類別的屬性來列舉。

using System;
using System.Management;

// This sample demonstrates how to
// enumerate all properties in a
// ManagementObject using the
// PropertyDataEnumerator object.
class Sample_PropertyDataEnumerator
{
    public static int Main(string[] args)
    {
        ManagementObject disk = new
            ManagementObject("Win32_LogicalDisk.DeviceID='C:'");
        PropertyDataCollection.PropertyDataEnumerator
            propertyEnumerator = disk.Properties.GetEnumerator();
        while(propertyEnumerator.MoveNext())
        {
            PropertyData p =
                (PropertyData)propertyEnumerator.Current;
            Console.WriteLine("Property found: " + p.Name);
        }
        return 0;
    }
}
Imports System.Management

' This sample demonstrates how to
' enumerate all properties in a
' ManagementObject using
' PropertyDataEnumerator object.
Class Sample_PropertyDataEnumerator
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer
        Dim disk As New ManagementObject( _
            "Win32_LogicalDisk.DeviceID='C:'")
        Dim propertyEnumerator As _
          PropertyDataCollection.PropertyDataEnumerator _
              = disk.Properties.GetEnumerator()
        While propertyEnumerator.MoveNext()
            Dim p As PropertyData = _
                CType(propertyEnumerator.Current, PropertyData)
            Console.WriteLine("Property found: " & p.Name)
        End While
        Return 0
    End Function
End Class

屬性

Current

取得 PropertyDataCollection 列舉中的目前 PropertyData

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MoveNext()

移至 PropertyDataCollection 列舉中的下一個項目。

Reset()

將列舉值重設為 PropertyDataCollection 列舉的開頭。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IEnumerator.Current

取得集合中目前的物件。

適用於