You may also want to use "out". With "ref", the values should already exist before the method call, while with "out", the method creates new values. The compiler will support this.
For example, this will cause the compiler to complain about "Use of unassigned variables" for both 'val1' and 'val2':
void test(ref T arg1, ref T arg2)
{
}
void myMethod()
{
T val1, val2;
// val1 and val2 should be created here to prevent error
test(ref val1, ref val2); // <---- compiler error is for this line
}
On the other hand, this one will warn you that 'arg1' and 'arg2' "must be assigned before control leaves the method".
void test(out T arg1, out T arg2) // <---- compiler error is for this line
{
// arg1 and arg2 should be created here to prevent error
}
void myMethod()
{
T val1, val2;
test(out val1, out val2);
}