語言

Uri.UserInfo 屬性

定義

取得與指定 URI 相關的使用者名稱、密碼或其他使用者專屬資訊。

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

屬性值

與 URI 相關的使用者資訊。 回傳的值不包含用來界定 URI 中使用者資訊部分的 '@' 字元。

例外狀況

此實例代表一個相對 URI,且此性質僅適用於絕對 URI。

範例

以下範例建立一個 Uri 實例並將使用者資訊寫入主控台。

Uri uriAddress = new Uri ("http://user:password@www.contoso.com/index.htm ");
Console.WriteLine(uriAddress.UserInfo);
Console.WriteLine("Fully Escaped {0}", uriAddress.UserEscaped ? "yes" : "no");
let uriAddress = Uri "http://user:password@www.contoso.com/index.htm "
printfn $"{uriAddress.UserInfo}"
printfn $"""Fully Escaped {if uriAddress.UserEscaped then "yes" else "no"}"""
Dim uriAddress As New Uri("http://user:password@www.contoso.com/index.htm ")
Console.WriteLine(uriAddress.UserInfo)
Console.WriteLine("Fully Escaped {0}", IIf(uriAddress.UserEscaped, "yes", "no")) 'TODO: For performance reasons this should be changed to nested IF statements

備註

此屬性回傳的值通常格式為「userName:password」。

適用於