ManagementBaseObject.Item[String] 属性

定义

通过 [] 符获取对属性值的访问。Gets access to property values through [] notation. 此属性是 ManagementBaseObject 类的索引器。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. 但是,在某个类上指定 expando 特性将自动提供一个类型为 Object、索引类型为 String 的默认索引属性。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

参数

propertyName
String

相关的属性的名称。The name of the property of interest.

属性值

特定类属性的管理对象。The management object for a specific class property.

示例

下面的示例演示如何使用 ManagementClass 构造函数初始化 ManagementClass 变量,然后获取 WMI 类的所有实例。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

注解

属性值Property Value

一个对象实例,其中包含所请求的属性的值。An object instance that contains the value of the requested property.

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

适用于