Uredi

Deli z drugimi prek


ManagementBaseObject.Item[String] Property

Definition

Gets access to property values through [] notation. This property is the indexer for the ManagementBaseObject class. You can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed property whose type is Object and whose index type is String.

public:
 property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ propertyName); void set(System::String ^ propertyName, System::Object ^ value); };
public object this[string propertyName] { get; set; }
member this.Item(string) : obj with get, set
Default Public Property Item(propertyName As String) As Object

Parameters

propertyName
String

The name of the property of interest.

Property Value

The management object for a specific class property.

Examples

The following example shows how to initialize a ManagementClass variable with a ManagementClass constructor and then get all the instances of a WMI class.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {
        ManagementClass c = new ManagementClass("Win32_Process");
        foreach (ManagementObject o in c.GetInstances())
            Console.WriteLine(
                "Next instance of Win32_Process : {0}", o["Name"]);
    }
}
Imports System.Management


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

        Dim c As New ManagementClass("Win32_Process")
        Dim o As ManagementObject
        For Each o In c.GetInstances()
            Console.WriteLine( _
                "Next instance of Win32_Process : {0}", o("Name"))
        Next o

    End Function
End Class

Remarks

Property Value

An object instance that contains the value of the requested property.

.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