using System; // dynamic with anonymous method mutator class C { static Action Test (T t) { return l => { dynamic d = l; d.Method (l); }; } static Action Test2 (T t) { T l = t; return () => { T l2 = l; Action a = () => { dynamic d = l2; d.Method (l); }; a (); }; } static Action Test3 (T t) { return l => { dynamic d = l; d.MethodRef (ref l); }; } static Action Test4 (T t) { T l = t; return () => { dynamic d = l; d.MethodRef (ref l); }; } void Method (object arg) { } void MethodRef (ref C arg) { arg = new C (); } public static int Main () { Test (null) (new C ()); Test2 (new C ()) (); Test (null) (new C ()); Test4 (new C ()) (); return 0; } }