The only difference between out
and ref
parameters is that an out
parameter will have an [out]
token applied to it. They're the same thing as far as the CLR is concerned.
In order to implement it, the compiler would have to generate ref
fields, which are not supported.
If you think about it, you'll realize that it makes no sense to allow an anonymous method to use an out
parameter.
What would the following code to?
static Func<object, object> Mess(out object param) {
param = "Original";
return i => param = i;
}
static Func<object, object> MessCaller() {
object local;
return Mess(out local);
}
static vouid Main() {
Console.WriteLine(MessCaller()("New"));
//The local variable that the lambda expression writes to doesn't exist anymore.
}