PropertyDataCollection 類別

定義

表示 WMI 物件的屬性集。

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

範例

下列範例會使用 類別列出 Win32_OperatingSystem 類別 PropertyData 的相關資訊。 如需 Win32_OperatingSystem的詳細資訊,請參閱 Windows Management Instrumentation 檔。

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class
        ManagementClass osClass =
            new ManagementClass("Win32_OperatingSystem");

        osClass.Options.UseAmendedQualifiers = true;

        // Get the Properties in the class
        PropertyDataCollection properties =
            osClass.Properties;

        // display the Property names
        Console.WriteLine("Property Name: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(
                "---------------------------------------");
            Console.WriteLine(property.Name);
            Console.WriteLine("Description: " +
                property.Qualifiers["Description"].Value);
            Console.WriteLine();

            Console.WriteLine("Type: ");
            Console.WriteLine(property.Type);

            Console.WriteLine();

            Console.WriteLine("Qualifiers: ");
            foreach(QualifierData q in
                property.Qualifiers)
            {
                Console.WriteLine(q.Name);
            }
            Console.WriteLine();

            foreach (ManagementObject c in osClass.GetInstances())
            {
                Console.WriteLine("Value: ");
                Console.WriteLine(
                    c.Properties[property.Name.ToString()].Value);

                Console.WriteLine();
            }
        }
    }
}
Imports System.Management


Public Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim osClass As ManagementClass = _
            New ManagementClass("Win32_OperatingSystem")

        osClass.Options.UseAmendedQualifiers = True

        ' Get the Properties in the class
        Dim properties As PropertyDataCollection = _
            osClass.Properties

        ' display the Property names
        Console.WriteLine("Property Name: ")
        For Each p As PropertyData In properties

            Console.WriteLine( _
                "---------------------------------------")
            Console.WriteLine(p.Name)
            Console.WriteLine("Description: " & _
                p.Qualifiers("Description").Value)
            Console.WriteLine()

            Console.WriteLine("Type: ")
            Console.WriteLine(p.Type)

            Console.WriteLine()

            Console.WriteLine("Qualifiers: ")
            For Each q As QualifierData In _
                p.Qualifiers

                Console.WriteLine(q.Name)
            Next
            Console.WriteLine()

            For Each c As ManagementObject In osClass.GetInstances()

                Console.WriteLine("Value: ")
                Console.WriteLine( _
                    c.Properties(p.Name.ToString()).Value)

                Console.WriteLine()
            Next
        Next

    End Function
End Class

屬性

Count

取得 PropertyDataCollection 中的物件數目。

IsSynchronized

取得值,指出物件是否已同步化。

Item[String]

使用 [] 語法,從 PropertyDataCollection 取得指定的屬性。 這個屬性就是 PropertyDataCollection 類別的索引子 (Indexer)。

SyncRoot

取得要用於同步處理的物件。

方法

Add(String, CimType, Boolean)

加入不具有指派值的新 PropertyData

Add(String, Object)

加入具有指定值的新 PropertyData。 這個值不得為 null 而且必須可轉換為通用訊息模型 (CIM) 型別。

Add(String, Object, CimType)

加入具有指定值和通用訊息模型 (CIM) 型別的新 PropertyData

CopyTo(Array, Int32)

PropertyDataCollection 複製到陣列。

CopyTo(PropertyData[], Int32)

PropertyDataCollection 複製至特殊的 PropertyData 物件陣列。

Equals(Object)

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

(繼承來源 Object)
GetEnumerator()

傳回這個 PropertyDataCollection 的列舉值。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(String)

PropertyDataPropertyDataCollection 中移除。

ToString()

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

(繼承來源 Object)

明確介面實作

IEnumerable.GetEnumerator()

傳回透過 IEnumerator 重複的 PropertyDataCollection

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於