out
orパラメータに割り当てを行うref
と、その値は呼び出し元によって提供された参照にすぐに割り当てられますか? または、メソッドが戻るときにout
andパラメータ値が参照に割り当てられますか? ref
メソッドが例外をスローした場合、値は返されますか?
例えば:
int callerOutValue = 1;
int callerRefValue = 1;
MyMethod(123456, out callerOutValue, ref callerRefValue);
bool MyMethod(int inValue, out int outValue, ref int refValue)
{
outValue = 2;
refValue = 2;
throw new ArgumentException();
// Is callerOutValue 1 or 2?
// Is callerRefValue 1 or 2?
}