.NET by Patrik

URI Example

In .NET, the System.Uri class is used to represent URIs. You can create a Uri object by passing a URI string to its constructor. The Uri class provides various properties and methods for working with different components of the URI, such as the scheme, host, path, query, and fragment.

Here's a simple example in C#:

// Creating a Uri object
Uri uri = new Uri("https://www.example.com/path/to/resource");

// Accessing components of the URI
Console.WriteLine($"Scheme: {uri.Scheme}");
Console.WriteLine($"Host: {uri.Host}");
Console.WriteLine($"Path: {uri.AbsolutePath}");
Console.WriteLine($"Query: {uri.Query}");

This example demonstrates creating a Uri object from a URL string and accessing different components of the URI using properties like Scheme, Host, AbsolutePath, and Query.

Comments