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 = gcnew Uri( "http://user:password@www.contoso.com/index.htm " );
Console::WriteLine( uriAddress->UserInfo );
Console::WriteLine( "Fully Escaped {0}",
   uriAddress->UserEscaped ? (String^)"yes" : "no" );
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」。

適用於