I think struct should able to made readonly in method parameter, not only in declaration #4741
-
After this article is written I then found out my issue actually dosn't exist. This text is a fault, I want to delete it but can not find the button. Don't read this to waste your time. Admin may just delete this if its posible.BackGroundwe know that we usually have methods including value type as parameter, such as:
However the
The
With such implementation, we got both performance and safe code manner. But a new issue rise. IssueBecause the struct
This is actually causing another performance problem, creating a new instance for the whole type's field, which includes even unchanged fields, is abviously costing much more than just changing the value of a single field. Possible SolutionI would be glad to see something like this:
As illustrated above, both reference and fields in instance are secured with immutablity, just like combination of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think there is no delete option - but you can mark it as answered |
Beta Was this translation helpful? Give feedback.
I think there is no delete option - but you can mark it as answered