Uri::IsDefaultPort Property


Gets whether the port value of the URI is the default for this scheme.

Namespace:   System
Assembly:  System (in System.dll)

property bool IsDefaultPort {
	bool get();

Property Value

Type: System::Boolean

A Boolean value that is true if the value in the Port property is the default port for this scheme; otherwise, false.

Exception Condition

This instance represents a relative URI, and this property is valid only for absolute URIs.

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() );

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top