ManagementBaseObject.Item Property (System.Management)

Switch View :
ScriptFree
.NET Framework Class Library
ManagementBaseObject.Item Property

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.

Namespace:  System.Management
Assembly:  System.Management (in System.Management.dll)
Syntax

Visual Basic
Public Property Item ( _
	propertyName As String _
) As Object
	Get
	Set
C#
public Object this[
	string propertyName
] { get; set; }
Visual C++
public:
property Object^ Item[String^ propertyName] {
	Object^ get (String^ propertyName);
	void set (String^ propertyName, Object^ value);
}
F#
member Item : Object with get, set

Parameters

propertyName
Type: System.String
The name of the property of interest.

Property Value

Type: System.Object
Returns an Object value that contains the management object for a specific class property.
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.

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.

Visual Basic

Imports System
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


C#

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"]);

    }
}


Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
.NET Framework Security

Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also

Reference