A string containing the query information included in the specified URI, or string.Empty .
The Uri.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.
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