How to make records equality case-insensitive for strings?

Viewed 382

I really like the C# 9 records. However, I can't find an elegant and concise way to accomplish somethink like this:

record MyKey(string Foo, int Bar);

[Fact]
public void ShouldEqualIgnoreCase()
{
    MyKey a = new("ID", 42);
    MyKey b = new("Id", 42);

    Assert.Equal(a, b);
}
0 Answers
Related