Query Property
Collapse the table of content
Expand the table of content

UriBuilder.Query Property

Gets or sets any query information included in the URI.

[Visual Basic]
Public Property Query As String
[C#]
public string Query {get; set;}
[C++]
public: __property String* get_Query();
public: __property void set_Query(String*);
[JScript]
public function get Query() : String;
public function set Query(String);

Property Value

The query information included in the URI.

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.

Setting the Query property to any value, including a null reference (Nothing in Visual Basic), clears the Fragment property. Setting the Query property to a null reference (Nothing) or to String.Empty clears the property.

Example

[Visual Basic, C#, C++] The following example writes the query ?date= today to the console.

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


[C#] 
Uri baseUri = new Uri("http://www.contoso.com/");
 Uri myUri = new 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);
   

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

UriBuilder Class | UriBuilder Members | System Namespace

Show:
© 2016 Microsoft