0
kicks
When Linq and ref Parameters Meet
In this post we look into a curious quirk of C#: you can't use parameters passed as "ref" inside a Linq query (or a lambda expression or anonymous method either). By analysing the intermediate code produced by the C# compiler, we learn how anonymous methods are compiled when they need lexical scoping semantics. Finally, an attempt to change the IL to get the desired semantics reveals why C# forbids this.