Edited by @MihaZupan on 2024-02-16
Background and motivation
For a long time, the System.Uri type has provided equality comparison operations via the object.Equals(object?) method and the operator ==() & operator !=() operators. Therefore, there is no reason not to further implement the IEquatable<Uri> interface.
API Proposal
namespace System;
-public partial class Uri : ISpanFormattable, ISerializable
+public partial class Uri : ISpanFormattable, ISerializable, IEquatable<Uri>
{
// Existing
public override bool Equals(object? comparand);
+ public bool Equals(Uri? other);
}
API Usage
IEquatable<Uri> a = new Uri("https://example.com/a");
IEquatable<Uri> b = new Uri("https://example.com/b");
Console.WriteLine("Equals? {0}", a.Equals(b));
Alternative Designs
No response
Risks
No response
Edited by @MihaZupan on 2024-02-16
Background and motivation
For a long time, the
System.Uritype has provided equality comparison operations via theobject.Equals(object?)method and theoperator ==()&operator !=()operators. Therefore, there is no reason not to further implement theIEquatable<Uri>interface.API Proposal
API Usage
Alternative Designs
No response
Risks
No response