Uri.IsDefaultPort Propriété

Définition

Obtient une valeur indiquant si la valeur du port de l'URI est la valeur par défaut pour ce schéma.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

Valeur de propriété

Valeur Boolean égale à true si la valeur de la propriété Port est le port par défaut de ce schéma ; sinon, false.A Boolean value that is true if the value in the Port property is the default port for this scheme; otherwise, false.

Exceptions

Cette instance représente un URI relatif, et cette propriété est uniquement valide pour les URI absolus.This instance represents a relative URI, and this property is valid only for absolute URIs.

Exemples

L’exemple suivant crée une instance de Uri et vérifie si elle utilise le port par défaut.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

S’applique à