C# Uri Port

Description

Uri Port gets the port number of this URI.

Syntax

Uri.Port has the following syntax.


public int Port { get; }

Example

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


/*from www.  j  a v a2s  .  c o m*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Uri baseUri = new Uri("http://www.java2s.com/");
    Uri myUri = new Uri(baseUri,"catalog/shownew.htm?date=today");
    
    Console.WriteLine(myUri.Port);
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version