This documentation is archived and is not being maintained.

Uri.Port Property

Gets the port number of the specified URI.

[Visual Basic]
Public ReadOnly Property Port As Integer
public int Port {get;}
public: __property int get_Port();
public function get Port() : int;

Property Value

The integer port number of the specified URI.


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


The following example writes the URI's port number to the console. In this case, the value is the default port number for HTTP, port 80.

[Visual Basic] 
Dim baseUri As New Uri("")
Dim myUri As New Uri(baseUri, "catalog/shownew.htm?date=today")

Uri baseUri = new Uri("");
 Uri myUri = new Uri(baseUri,"catalog/shownew.htm?date=today");

Uri* baseUri = new Uri(S"");
Uri* myUri = new Uri(baseUri,S"catalog/shownew.htm?date=today");

var baseUri : Uri = new Uri("");
var myUri : Uri = new Uri(baseUri,"catalog/shownew.htm?date=today");


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Uri Class | Uri Members | System Namespace