Adding a Clone method to a C# record
Adding a Clone method to a C# record When using records, creating a copy with with is concise: var sample = new Sample("meziantou"); _ = sample with { }; public record Sample(string Value); This works well, but sample with { } is not always obvious as a discoverable Clone API for consumers. Why public Sample Clone() is not allowed Records already have compiler-generated clone behavior used by with.… [read more]