I cannot try rigth now, but I am sure, someone knows:
void func(out MyType A) {
A = new MyType();
// do some other stuff here
// take some time ... and return
}
When I call this in an asynchronous manner like that:
MyType a;
func(out a);
will a be altered immediately, once A is assigned in the function? Or is the new object reference assigned to a only when the function returns?
Are there any specifications if I want to relay on the currently implemented behavior?
It’s assigned once A is assigned in the function. The use of
outprovides a reference to whatever you passed in, which means it gets modified whenever it is modified in the method.An extract from the C# language spec: