System.Uri.Port Property

Gets the port number of this URI.

Syntax

public int Port { get; }

Value

A int containing the port number, or -1 if no port is used by the URI Uri.Scheme . If no port was specified as part of the URI used to construct the current instance, the Uri.Port property returns the default port for the URI scheme.

Remarks

The port number defines the protocol port used for contacting the server referenced in the URI. If a port is not specified as part of the URI, the Uri.Port property returns the default value for the protocol. If there is no default port number, this property returns -1.

Requirements

Namespace: System
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0