Export (0) Print
Expand All

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

Property Value

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

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

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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft