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

定义

获取指定 URI 中包括的任何查询信息。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

属性值

一个String,包含指定 URI 中包括的任何查询信息。A String that contains any query information included in the specified URI.

异常

此实例代表一个相对 URI,而此属性仅对绝对 URI 有效。This instance represents a relative URI, and this property is valid only for absolute URIs.

示例

下面的示例将查询? date = today 写入控制台。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)

注解

Query属性包含 URI 中包括的任何查询信息。The Query property contains any query information included in the URI. 查询信息由问号(?)与路径信息分隔开来,并继续到 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.

默认情况下,根据 RFC 2396 对查询信息进行转义。The query information is escaped according to RFC 2396 by default. 如果启用了国际资源标识符(IRIs)或国际化域名(IDN)分析,将根据 RFC 3986 和 RFC 3987 对查询信息进行转义。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.

有关 IRI 支持的详细信息,请参阅Uri类的 "备注" 部分。For more information on IRI support, see the Remarks section for the Uri class.

适用于