In this form, this is not possible. Your lamda is compiled into bytecode. Although it is theoretically possible to decompile the bytecode, just like a reflector, it is difficult, error prone and does not give you the exact code that you compiled, but simply the code equivalent.
If you use Expression<Action> instead of a simple Action , you will get an expression tree that describes lamda. And it is possible to convert the expression tree to a string (and there are existing libraries that do this).
But this is not possible in your example, because it is a verbose lamda instruction. And only simple lams can be automatically converted to an expression tree.
CodesInChaos
source share