The blogged wandering of Robert W. Anderson
Can someone explain why the following expression evaluates to true? There must be some historical perspective that I’m just missing.
new Uri("mailto:email@example.com") == new Uri("mailto:firstname.lastname@example.org")
I would understand:
- A use case for a separate Uri.Compare method giving the caller control over which components should be compared;
- If Uri.Equals performed its comparison against canonicalized URIs.
The docs say that the user info, fragment, and (in older .NETs) query are all ignored for comparison. There is no mention for the email address in a mailto; however.
Tags: .NET, BCL, c#, Microsoft
Did you mean those to be identical?
Thanks, Dan. Arg. I mean Argh. Haven’t blogged in a month and now I’m 0 for 2. I’ve corrected the post — LiveWriter kept “smartly” converting my code into link tags — I must have messed up while undoing that.
Oh, because before I was pretty sure why that might evaluate to true.
Now, I’m as confused as you.
I might be totally off on this, but is the comparison being done at the object-type level? Perhaps it’s using the ToString() method for the comparison. In either case, they would both be [System.Uri]. Maybe you have to use the AbsoluteUri property to perform a valid comparison?
Shannon — I think you saw the original problem post — as it was, you are right they correclty compared to the same value, though not the same object.
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>