Uri.IsDefaultPort Propiedad

Definición

Obtiene un valor que indica si el valor de puerto del identificador URI es el valor predeterminado para este esquema.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

Valor de propiedad

Valor Boolean que es true si el valor de la propiedad Port es el puerto predeterminado para este esquema; en caso contrario, false.A Boolean value that is true if the value in the Port property is the default port for this scheme; otherwise, false.

Excepciones

Esta instancia representa un identificador URI relativo, y esta propiedad sólo es válida para identificadores URI absolutos.This instance represents a relative URI, and this property is valid only for absolute URIs.

Ejemplos

En el ejemplo siguiente se crea una instancia de Uri y se comprueba si usa el puerto predeterminado.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

Se aplica a