The scope of variable in inner anonymous method
问题 See the code public class Test { public static void Main() { Test t = new Test(); var AnonymousMethod = t.OuterMethod(); AnonymousMethod("passedValue"); } public delegate void SampleDelegate(string InputText); public SampleDelegate OuterMethod() { string outerValue="outerValue"; return (x => { Console.WriteLine(x); Console.WriteLine(outerValue); }); } } OutPut Success time: 0.02 memory: 33816 signal:0 passedValue outerValue Link to Example Normally the scope of variable outerValue would end