using System; class DelegateFlow { void M1(int i) { } static void M2(Action a) { a(0); a = _ => { }; a(1); } void M3() { M2(_ => { }); M2(M1); } void M4(Action a) { M2(a); } void M5() { M4(_ => { }); M4(M1); } void M6(Action> aa, Action a) { aa(a); } void M7() { M6(a => { a(1); }, M1); } Action Prop { get { return _ => { }; } set { value(0); } } void M8() { dynamic d = this; d.Prop = d.Prop; } static Func> F = () => _ => { }; void M9() { F()(0); } Action M10() { return _ => { }; } void M11() { M10()(0); } public delegate void EventHandler(); public event EventHandler Click; public void M12() { Click += M11; Click(); M13(M9); } public void M13(EventHandler eh) { Click += eh; Click(); } public void M13() { void M14(MyDelegate d) => d(); M14(new MyDelegate(M9)); M14(new MyDelegate(new MyDelegate(M11))); M14(M12); M14(() => { }); } public void M14() { void LocalFunction(int i) { }; M2(LocalFunction); } public void M15() { Func f = () => 42; new Lazy(f); f = () => 43; new Lazy(f); } public delegate void MyDelegate(); public unsafe void M16(delegate*, void> fnptr, Action a) { fnptr(a); } public unsafe void M17() { M16(&M2, (i) => { }); } public unsafe void M18() { delegate*, void> fnptr = &M2; fnptr((i) => { }); } void M19(Action a, bool b) { if (b) a = () => { }; a(); } void M20(bool b) => M19(() => { }, b); Action Field; Action Prop2 { get; set; } DelegateFlow(Action a, Action b) { Field = a; Prop2 = b; } void M20() { new DelegateFlow( _ => { }, _ => { } ); this.Field(0); this.Prop2(0); Field(0); Prop2(0); } }