I wrote a FillSomeData(ParameterData param, Result res)
method, which populates res
with some data (just like it says on the label).
Result
is a class, not a struct, so FillSomeData
actually affects res
.
Following a code review, my colleagues insist that I add a ref
to the method signature (changing it to FillSomeData(ParameterData param, ref Result res)
), merely in order to make it clear that the method changes res
.
I believe this is not the intention of the ref
keyword, and that this is wrong.
What is the common and recommended practice in such situations?
ref
means changing the variable passed in and not mutating a reference type. – CodesInChaos Jun 4 '17 at 11:30