Uri.Query Uri.Query Uri.Query Uri.Query Property

Definition

Gets any query information included in the specified URI.

public:
 property System::String ^ Query { System::String ^ get(); };
public string Query { get; }
member this.Query : string
Public ReadOnly Property Query As String

Property Value

A String that contains any query information included in the specified URI.

Exceptions

This instance represents a relative URI, and this property is valid only for absolute URIs.

Examples

The following example writes the query ?date= today to the console.

Uri^ baseUri = gcnew Uri( "http://www.contoso.com/" );
Uri^ myUri = gcnew Uri( baseUri, "catalog/shownew.htm?date=today" );

Console::WriteLine( myUri->Query );
Uri baseUri = new Uri ("http://www.contoso.com/");
Uri myUri = new Uri (baseUri, "catalog/shownew.htm?date=today");

Console.WriteLine (myUri.Query);
Dim baseUri As New Uri("http://www.contoso.com/")
Dim myUri As New Uri(baseUri, "catalog/shownew.htm?date=today")

Console.WriteLine(myUri.Query)

Remarks

The Query property contains any query information included in the URI. Query information is separated from the path information by a question mark (?) and continues to the end of the URI. The query information returned includes the leading question mark.

The query information is escaped according to RFC 2396 by default. If International Resource Identifiers (IRIs) or Internationalized Domain Name (IDN) parsing is enabled, the query information is escaped according to RFC 3986 and RFC 3987.

For more information on IRI support, see the Remarks section for the Uri class.

Applies to