What is the standard way to determine that these 2 similar Uris are actually the same?
var a = new Uri("http://sample.com/sample/");
var b = new Uri("http://sample.com/sample");
Console.WriteLine(a.Equals(b));
// False
What is the best way to determine that a == b? I could compare the sub properties of the Uri object such as Host, LocalPath, etc, but I'm wondering if there is a better way.
Edit: Thanks everybody. I basically just have to have the user enforce whether that are the same or not.
The Uri class overrides Equals
and implements the ==
operator in order to determine equality.
The way to test if the two Uri instances are equivalent is:
if(a == b)
In your case, they are not equivalent. The directory terminator at the end of a
has specific meaning, whereas b
might be a directory or a file.
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