The function fool1
doesn’t change the args
variable from the calling method. It only changes it inside the fool
method (so the reference changes).
string a = "x";
fool1(a);
// a is still "x"
Function fool2
DOES change the args
variable from the calling method.
string a = "x";
fool2(ref a);
// a is "xABCD"
Function fool3
doesn’t change the args
variable from the calling method.
string a = "x";
string b = fool3(a);
// a is "x", b is "xABCD"
solved Value type and reference type with c#.NET code sample? [closed]