ManagementObject.Get Method ()


Binds WMI class information to the management object.

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

public void Get()

The method is implicitly invoked at the first attempt to get or set information to the WMI object. It can also be explicitly invoked at the user's discretion, to better control the timing and manner of retrieval.

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.

The following example calls the Get method to get an instance of the ManagementObject class.

using System;
using System.Management;

class Sample
    public static int Main(string[] args) 
        ManagementObject o = 
            new ManagementObject("MyClass.Name='abc'");

        //this causes an implicit Get().
        string s = o["Name"].ToString();


        //or :

        ManagementObject mObj = 
            new ManagementObject("MyClass.Name= 'abc'");
        mObj.Get(); //explicitly 
        // Now it is faster because the object
        // has already been retrieved.
        string property = mObj["Name"].ToString();


        return 0;

.NET Framework
Available since 1.1
Return to top