PropertyDataCollection.Item[String] 属性

定义

使用 [] 语法从 PropertyDataCollection 中获取指定属性。Gets the specified property from the PropertyDataCollection, using [] syntax. 此属性是 PropertyDataCollection 类的索引器。This property is the indexer for the PropertyDataCollection class.

public:
 virtual property System::Management::PropertyData ^ default[System::String ^] { System::Management::PropertyData ^ get(System::String ^ propertyName); };
public virtual System.Management.PropertyData this[string propertyName] { get; }
member this.Item(string) : System.Management.PropertyData
Default Public Overridable ReadOnly Property Item(propertyName As String) As PropertyData

参数

propertyName
String

要检索的属性的名称。The name of the property to retrieve.

属性值

返回一个 PropertyData,它包含集合中指定属性的数据。Returns a PropertyData containing the data for a specified property in the collection.

示例

下面的示例从ManagementClass获取可用空间属性。The following example gets the Freespace property from a ManagementClass.

using System;
using System.Management;
   
public class Sample
{
    public static void Main(string[] args) 
    {
        ManagementObject m = new ManagementObject(
            "Win32_LogicalDisk.DeviceID=\"C:\"");
        Console.WriteLine("Free space on drive C is: " +
            m.Properties["Freespace"].Value + " bytes");
    }
}
Imports System.Management

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

        Dim m As New ManagementObject( _
            "Win32_LogicalDisk.DeviceID=""C:""")
        Console.WriteLine( _
            m.Properties("FreeSpace").Value)

        Return 0
    End Function
End Class

注解

属性值Property Value

PropertyData, 基于指定的名称。A PropertyData, based on the name specified.

.NET Framework 安全性.NET Framework Security

对直接调用方的完全信任。Full trust for the immediate caller. 此成员不能由部分信任的代码使用。This member cannot be used by partially trusted code. 有关详细信息, 请参阅从部分受信任的代码使用库For more information, see Using Libraries from Partially Trusted Code.

适用于