ValueObject → record #866
-
Hi everyone! |
Beta Was this translation helpful? Give feedback.
Answered by
CapitanMurloc
Jan 5, 2021
Replies: 1 comment
-
Hi @leotsarev, Example: public record Address(string Street, string ZipCode); IComparable interfaceUnfortunately, C# records don’t implement the IComparable interface, which means that the following code doesn’t work: var address1 = new Address("1234 Main St", "20012");
var address2 = new Address("1235 Main St", "20012");
Address[] addresses = new[] { address1, address2 }.OrderBy(x => x).ToArray(); If you try to run it, .NET will throw an exception:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rasmus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @leotsarev,
Example:
IComparable interface
Unfortunately, C# records don’t implement the IComparable interface, which means that the following code doesn’t work:
If you try to run it, .NET will throw an exception:
C# 9 Records as DDD Value Objects