Add in the ability to customize the copy semantics for structure types. #7556
Replies: 3 comments 4 replies
-
Structs are copied by value, they don't require a clone method like classes do. When you use |
Beta Was this translation helpful? Give feedback.
-
As noted on discord, here's the meeting notes where this was decided: https://github.com/dotnet/csharplang/blob/main/meetings/2020/LDM-2020-09-30.md#with-expressions. |
Beta Was this translation helpful? Give feedback.
-
I think there have been so many requests about the struct topic, that some decisions should be revised. Especially copy semantics and destructors are often requested. Sure, this topic might be complex, but would solve a lot of problems. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all!
I was recently playing with the new
record struct
type and noticed that in the docs on Custom Copy Semantics it mentions that "You can't customize the copy semantics for structure types."Is there any specific reason for this? Is there anyway around it? I'd really like to do something like this:
Instead right now, the copy semantic is ignored, not used, and both
a
andb
have the same ID.Notably this does work if
Entity
is instead arecord class
/record
.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions