I'm looking it over and it seems to be that it is fundamentally broken.
So is there anything it is good for? Should I really be using this instead of just strings?
A URI is a compact representation of a resource available to your application on the intranet or internet. The Uri class defines the properties and methods for handling URIs, including parsing, comparing, and combining. The Uri class properties are read-only; to create a modifiable object, use the UriBuilder class.
Uri(String, UriKind) Initializes a new instance of the Uri class with the specified URI. This constructor allows you to specify if the URI string is a relative URI, absolute URI, or is indeterminate. Uri(Uri, String) Initializes a new instance of the Uri class based on the specified base URI and relative URI string.
A URI is short for Uniform Resource Identifier. This URI is a string that contains 1. The URL you are pointing towards, 2. The information you are trying to passover.
A Uniform Resource Identifier (URI) is a unique sequence of characters that identifies a logical or physical resource used by web technologies. URIs may be used to identify anything, including real-world objects, such as people and places, concepts, or information resources such as web pages and books.
I wouldn't say the Uri class is fundamentally broken at all. The purpose of the Uri class is to provide a compact and standard representation of a URI. The Uri class encapsulates all of the logic needed to return the URI in a canonical form and to provide support for IPV4 and IPV6 notations, and IRI support.
The Uri class is not designed to allow changing the Uri once it has been created; if you want that level of mutability you should use a UriBuilder instead.
The benefit to using Uri (or UriBuilder) over strings is that you get a lot of validation built in to ensure that the given address is well-formed, capabilities to make relative URIs from absolute ones, etc. Essentially, you can think of a Uri as an actual data type, so using one provides a level of strong typing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With