Mono Class Library: System.Uri Overview | Members

System.Uri.Query Property

Gets the query component of the URI used to construct the current instance. [Edit]

public string Query { get; }

Value

A string containing the query information included in the specified URI, or string.Empty . [Edit]

Remarks

This property is read-only.

If, when the current instance was constructed, the URI was already escaped or the constructor's dontEscape parameter was set to false , the value returned by this property is escaped.

Note: Query information is separated from the path information by a question mark ('?') and is located at the end of a URI. The query information includes the leading question mark.

[Edit]

Example

The following example uses the Uri.Query property to extract the query from a URI.

C# Example
using System;

public class UriTest {
 public static void Main() {

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

The output is

?date=today

Requirements

Namespace: System
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0