void Method(ref int refArgument)
{
refArgument = refArgument + 44;
}
int number = 1;
Method(ref number);
Console.WriteLine(number);
Under the hood, what is really happening?
It passes the memory address to the method/function and changes the value stored in that memory address?
OR
It creates a new memory address and stores the value in that newly created address and points the variable(number) to the new memory address?
Which is which?
My hunch is the first one since primitive data types in C# are struct and therefore they will always be pass by value
ldloca
,ldind
. LINQPad is your friend.number
updated when you assign torefArgument
, or only whenMethod
finishes?' the answer is the former.