The Uri Type

In the world of massively connected systems, addressing of endpoints is quite common, so it makes sense to have a built-in primitive for uniform resource identifiers (URIs). The Uri class provided for this purpose supports both absolute and relative URIs and has a bunch of properties to query the various parts of a URI. A basic example is shown here:

image

Lots of complexities exist with regard to escaping, security of hostnames, and so forth. This is one of the reasons why Uri is an immutable type, so you can’t go and tweak parts of it by touching the various properties. To create new Uri objects from parts, don’t use techniques like string ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.