using System; class Program { static void Main(string[] args) { Uri uri = new Uri("https://www.example.com/path?query=value#fragment"); Console.WriteLine("Host: " + uri.Host); Console.WriteLine("Path: " + uri.PathAndQuery); Console.WriteLine("Query: " + uri.Query); Console.WriteLine("Fragment: " + uri.Fragment); } }
using System; using System.Net; class Program { static void Main(string[] args) { WebClient webClient = new WebClient(); Uri uri = new Uri("https://www.example.com"); string html = webClient.DownloadString(uri); Console.WriteLine(html); } }This code uses the WebClient class to download the contents of a web page. The Uri object is used to specify the URL of the page. The global::System.Uri class is part of the .NET Framework and is included in the System assembly.