Uri.UserInfo 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取与指定 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”格式。