SelectQuery.QueryString Property


Gets or sets the query in the SelectQuery object, in string form.

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

public override string QueryString { get; set; }

Property Value

Type: System.String

Returns a String value containing the query.

Setting this property value overrides any previous value stored in the object. In addition, setting this property causes the other members of the object to be updated when the string is reparsed.

A string representing 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 with the default constructor and then changes the QueryString property.

using System;
using System.Management;

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

        ManagementObjectSearcher searcher = 
            new ManagementObjectSearcher(

        foreach (ManagementObject o in searcher.Get()) 
            // show the class

.NET Framework
Available since 1.1
Return to top