I still don't quite understand what a closure is so I posted these two examples and I want to know whether these examples are both closures or not?
Example A:
List<DirectoryInfo> subFolders = new List<DirectoryInfo>();
Action<string> FilterSubFoldersStartA =
s => subFolders.
AddRange((new DirectoryInfo(s)).GetDirectories().
Where(d => d.Name.StartsWith("A")));
FilterSubFoldersStartA(@"c:\tempa");
FilterSubFoldersStartA(@"c:\tempb");
Example B:
List<DirectoryInfo> subFolders = new List<DirectoryInfo>();
string filter = "A";
Action<string> FilterSubFoldersStartGen =
s => subFolders.
AddRange((new DirectoryInfo(s)).GetDirectories().
Where(d => d.Name.StartsWith(filter)));
FilterSubFoldersStartGen(@"c:\tempa");
filter = "B";
FilterSubFoldersStartGen(@"c:\tempb");