C#C
C#11mo ago
Odex

`readonly` struct, `in` modifier and defensive copies

Hi people, I just encountered the in modifier for structs.
As far as I'm concerned the in modifier can negatively affect performance if the struct I'm passing is NOT readonly, because it might create defensive copies - however, how can I avoid defensive copies without marking my struct readonly? Is there a rule of thumb when defensive copies are created?
Thanks in advance!
Was this page helpful?