Uri.IsDefaultPort Uri.IsDefaultPort Uri.IsDefaultPort Uri.IsDefaultPort Property

Definition

Ruft ab, ob der Portwert im URI der Standardwert für dieses Schema ist.Gets whether the port value of the URI is the default for this scheme.

public:
 property bool IsDefaultPort { bool get(); };
public bool IsDefaultPort { get; }
member this.IsDefaultPort : bool
Public ReadOnly Property IsDefaultPort As Boolean

Eigenschaftswert

Ein Boolean-Wert, der true ist, wenn der Wert in der Port-Eigenschaft der Standardport für dieses Schema ist, andernfalls false.A Boolean value that is true if the value in the Port property is the default port for this scheme; otherwise, false.

Ausnahmen

Diese Instanz stellt einen relativen URI dar, diese Eigenschaft ist jedoch nur für absolute URIs gültig.This instance represents a relative URI, and this property is valid only for absolute URIs.

Beispiele

Das folgende Beispiel erstellt eine Uri Instanz, und überprüft, ob es sich um den Standardport verwendet.The following example creates a Uri instance and checks whether it uses the default port.

// Create Uri
Uri^ uriAddress = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Console::WriteLine( uriAddress->Fragment );
Console::WriteLine( "Uri {0} the default port ", uriAddress->IsDefaultPort ? (String^)"uses" : "does not use" );

Console::WriteLine( "The path of this Uri is {0}", uriAddress->GetLeftPart( UriPartial::Path ) );
Console::WriteLine( "Hash code {0}", uriAddress->GetHashCode() );
// The example displays the following output:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291
// Create Uri
Uri uriAddress = new Uri("http://www.contoso.com/index.htm#search");
Console.WriteLine(uriAddress.Fragment);
Console.WriteLine("Uri {0} the default port ", uriAddress.IsDefaultPort ? "uses" : "does not use");
 
Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path));
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode());
// The example displays the following output:
//        #search
//        Uri uses the default port
//        The path of this Uri is http://www.contoso.com/index.htm
//        Hash code -988419291
' Create Uri
Dim uriAddress As New Uri("http://www.contoso.com/index.htm#search")
Console.WriteLine(uriAddress.Fragment)
Console.WriteLine("Uri {0} the default port ", If(uriAddress.IsDefaultPort, "uses", "does not use")) 

Console.WriteLine("The path of this Uri is {0}", uriAddress.GetLeftPart(UriPartial.Path))
Console.WriteLine("Hash code {0}", uriAddress.GetHashCode())
' The example displays the following output:
'        #search
'        Uri uses the default port
'        The path of this Uri is http://www.contoso.com/index.htm
'        Hash code -988419291

Gilt für: