Hello all!
I´m passing a reference using ref to a constructor in class A.
A a = new A(ref myObj);
If I change values of myObj in class A, they are reflected on the main class.
But, If I call a method like:
a.myMethod()
And change values of myObj (a private variable inside class A, assigned from ref by the constructor), they are not reflected on the main class.
Any work around? I dont want to use out or a return variable. It should work, because the reference was set in constructor.
Thanks!
I´m passing a reference using ref to a constructor in class A.
A a = new A(ref myObj);
If I change values of myObj in class A, they are reflected on the main class.
But, If I call a method like:
a.myMethod()
And change values of myObj (a private variable inside class A, assigned from ref by the constructor), they are not reflected on the main class.
Any work around? I dont want to use out or a return variable. It should work, because the reference was set in constructor.
Thanks!
Comment