Uri

In this chapter you will learn:

  1. Create Uri and print out properties

Create Uri

using System; /*from  j av a2 s  .c o m*/
using System.Net; 
 
class MainClass {  
  public static void Main() { 
 
    Uri sample = new Uri("http://www.yoursite.com/somefile.txt?SomeQuery"); 
 
    Console.WriteLine("Host: " + sample.Host); 
    Console.WriteLine("Port: " + sample.Port); 
    Console.WriteLine("Scheme: " + sample.Scheme); 
    Console.WriteLine("Local Path: " + sample.LocalPath); 
    Console.WriteLine("Query: " + sample.Query); 
    Console.WriteLine("Path and query: " + sample.PathAndQuery); 
 
  } 
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. Use WebClient to download web page into a file
  2. Download Data
  3. Upload Data
  4. Upload Values
Home » C# Tutorial » Network
Cookie
CredentialCache
HostEntry
IPHostEntry
IP address from host name
IPEndPoint from IPAddress
IPEndPoint Port
IPEndPoint properties
IPHostEntry
IP Address Parser
Predefined IP Address
NetworkCredential
Ping
Udp Client
Socket connection
Socket creation
Socket sendTo
TcpClient
TcpListener
UdpClient Receive
UdpClient Sending
Uri
WebClient
Response Headers
WebProxy
WebRequest