SelectQuery.ClassName Property

 

Gets or sets the class name to be selected from in the query.

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

public string ClassName { get; set; }

Property Value

Type: System.String

Returns a String value containing the name of the class in the query.

Setting this property value overrides any previous value stored in the object. The query string is rebuilt to reflect the new class name.

A value for the ClassName property would replace the <className> item in a SELECT query of the form "SELECT * FROM <className> WHERE <condition>".

A string representing the name of the class in the query.

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 initializes a SelectQuery by specifying a query and then changes the ClassName property.

using System; 
using System.Management;

class Sample 
{ 
    public static void Main(string[] args) 
    { 
        SelectQuery s = 
            new SelectQuery("SELECT * FROM Win32_LogicalDisk");

        //output is : SELECT * FROM Win32_LogicalDisk
        Console.WriteLine(s.QueryString);

        s.ClassName = "Win32_Process";

        //output is : SELECT * FROM Win32_Process
        Console.WriteLine(s.QueryString);
    }
}

.NET Framework
Available since 1.1
Return to top
Show: