Uri.Query 屬性

定義

取得指定 URI 中包含的任何查詢資訊,如果不是空的,則包含前置 '?' 字元。

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

屬性值

指定 URI 中包含的任何查詢資訊。

例外狀況

這個執行個體代表相對的 URI,而這個屬性只適用於絕對 URI。

範例

下列範例會將查詢 ?date=today 寫入主控台。

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);
let baseUri = Uri "http://www.contoso.com/"
let myUri = Uri (baseUri, "catalog/shownew.htm?date=today")

printfn $"{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 中包含的任何查詢資訊。 查詢資訊會以問號 (?) 分隔路徑資訊,並繼續到 URI 的結尾。 傳回的查詢資訊包含前置問號。

根據預設,查詢資訊會根據 RFC 2396 逸出。 如果啟用國際資源識別碼 (IRI) 或國際化功能變數名稱 (IDN) 剖析,則會根據 RFC 3986 和 RFC 3987 逸出查詢資訊。

如需 IRI 支援的詳細資訊,請參閱 類別的 Uri 一節。

適用於