Not really a ‘trick’ per se, but while I was trying to explain the LINQ mechanics to someone, I came up with this example. It’s the kind of thing that someone could argue is a compiler bug (which it isn’t), but only if they don’t understand how LINQ’s implemented (and specifically, how you can plug in your own code for the various extension methods called in the post-translation code).
Even if it were a compiler bug, it’s not one I would argue is worth fixing given the simplicity of the workaround (initialize the int to something). Once you do, you get the expected output of 123 and 234 on separate lines.
The below code will fail to compile with error CS0165: Use of unassigned local variable ‘outputInt’