Uri.HostNameType 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 URI 中所指定主機名稱的類型。
public:
property UriHostNameType HostNameType { UriHostNameType get(); };
public UriHostNameType HostNameType { get; }
member this.HostNameType : UriHostNameType
Public ReadOnly Property HostNameType As UriHostNameType
屬性值
UriHostNameType 列舉的成員。
例外狀況
這個執行個體代表相對的 URI,而這個屬性只適用於絕對 URI。
範例
下列範例會 Uri 建立 實例,並將 寫入 HostNameType 主控台。
Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Console::WriteLine( "address 1 {0} a valid scheme name",
Uri::CheckSchemeName( address1->Scheme ) ? (String^)" has" : " does not have" );
if ( address1->Scheme == Uri::UriSchemeHttp )
{
Console::WriteLine( "Uri is HTTP type" );
}
Console::WriteLine( address1->HostNameType );
Uri address1 = new Uri("http://www.contoso.com/index.htm#search");
Console.WriteLine("address 1 {0} a valid scheme name",
Uri.CheckSchemeName(address1.Scheme) ? " has" : " does not have");
if (address1.Scheme == Uri.UriSchemeHttp)
Console.WriteLine("Uri is HTTP type");
Console.WriteLine(address1.HostNameType);
let address1 = Uri "http://www.contoso.com/index.htm#search"
printfn $"""address 1 {if Uri.CheckSchemeName address1.Scheme then " has" else " does not have"} a valid scheme name"""
if address1.Scheme = Uri.UriSchemeHttp then
printfn "Uri is HTTP type"
printfn $"{address1.HostNameType}"
Dim address1 As New Uri("http://www.contoso.com/index.htm#search")
Console.WriteLine("address 1 {0} a valid scheme name", IIf(Uri.CheckSchemeName(address1.Scheme), " has", " does not have")) 'TODO: For performance reasons this should be changed to nested IF statements
If address1.Scheme = Uri.UriSchemeHttp Then
Console.WriteLine("Uri is HTTP type")
End If
Console.WriteLine(address1.HostNameType)