Ref C# - new assignment in foo, propagates to other functions using same reference? -
my basic question asking if change reference of ref in 1 method reflected in other method (like double pointers in c++)?
method() { referencetypeint t = new t(1); asynccall foo(ref t); bar(ref t); } foo(ref a) { = new t(3); } bar (ref a) { wait 10 seconds/until foo finishes; console.print ("t is" t.tostring()) }
the above rough pseudoish code, t 3 above?
yes, that's point of ref. indicates parameter should treated alias variable, assigning alter the variable itself. since ref again in bar, have alias, change reflected in output.
Comments
Post a Comment