Performance traps of ref locals and ref returns in C#
Be cautious with ref returns because they can break encapsulation.
Be cautious with readonly ref returns because they’re more performant only for readonly structs and could cause performance issues for regular structs.
Be cautious with readonly ref locals because they also could cause performance issues for non-readonly structs causing defensive copy each time the variable is used.
https://devblogs.microsoft.com/premier-developer/performance-traps-of-ref-locals-and-ref-returns-in-c/#struct #readonly #ref #performance