❔ base class/abstract for record
is the only way to do this and use the properties of a record to use method extensions
6 Replies
You can define the members in an interface
I just switched it back to a class. I wanted to add a tostring method
Which is the same across multiple record types
Stack Overflow
C# 9.0 records - ToString not inherited
consider:
// the ratioale for Wrapper is that it has a Json serializer that
// serialize through Field (not included in this example) record Wrapper<T> where T : notnull { protected Wrapp...
// serialize through Field (not included in this example) record Wrapper<T> where T : notnull { protected Wrapp...
If there's common behavior, you can make a static helper method to generate the string and call that in ToString
aye i think i'm going to avoid that, i want some overrides in there aswell for other things, so i'm just going to use a class i think
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.