|
|
|
@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
|
|
|
|
|
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
public static class DelegateConstruction |
|
|
|
|
{ |
|
|
|
@ -38,4 +39,24 @@ public static class DelegateConstruction
@@ -38,4 +39,24 @@ public static class DelegateConstruction
|
|
|
|
|
{ |
|
|
|
|
return new Func<string>(((string)null).ToUpper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static List<Action<int>> AnonymousMethodStoreWithinLoop() |
|
|
|
|
{ |
|
|
|
|
List<Action<int>> list = new List<Action<int>>(); |
|
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
|
int counter; |
|
|
|
|
list.Add(x => counter = x); |
|
|
|
|
} |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static List<Action<int>> AnonymousMethodStoreOutsideLoop() |
|
|
|
|
{ |
|
|
|
|
List<Action<int>> list = new List<Action<int>>(); |
|
|
|
|
int counter; |
|
|
|
|
for (int i = 0; i < 10; i++) { |
|
|
|
|
list.Add(x => counter = x); |
|
|
|
|
} |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|