Actually, you can use ref
and out
- just not directly with the calling method's parameters; you can, however, just copy the values before and after invoking:
static void Foo(ref string s, out int i)
{
string tmpS = s;
int tmpI = 0; // for definite assignment
DoIt(delegate { Bar(ref tmpS, out tmpI); });
s = tmpS;
i = tmpI;
}