////重构匿名方法,提取后 public static void Refactoring() { RefactAnonmousMethod p = new RefactAnonmousMethod(); int i = 10; /*begin extraction*/ //p.d = delegate { Console.WriteLine(i++); }; i = NewMethod(p, i); //p.d = delegate { Console.WriteLine(i++); }; /*end extraction*/ i++; p.d(); }
public static void RefactoringMethodTest() { RefactAnonmousMethod.Refactoring(); }
private static int NewMethod(RefactAnonmousMethod p, int i) { p.d = delegate { Console.WriteLine(i++); }; return(i); }