ערוך

שתף באמצעות


PropertyDataCollection.Item[String] Property

Definition

Gets the specified property from the PropertyDataCollection, using [] syntax. 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

Parameters

propertyName
String

The name of the property to retrieve.

Property Value

Returns a PropertyData containing the data for a specified property in the collection.

Examples

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

Remarks

Property Value

A PropertyData, based on the name specified.

.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.

Applies to