I have a method that I’m using to output all the class names in an Assembly:
private static void ListClasses()
{
var assembly = Assembly.LoadFile(@"path\to\my.dll");
Type[] types = assembly.GetTypes().Where(t => t.IsClass).ToArray();
using (StreamWriter w = File.AppendText("log.txt"))
{
foreach (var type in types)
{
w.WriteLine(type.Namespace + "," + type.Name);
w.Flush();
}
w.Close();
}
Console.WriteLine("Done");
}
The only problem I’m seeing is some of the class names have this output:
The.Namespace,_Closure$__1
The last number will increment each time the Type name needs to be output this way. Can anyone shed some light as to what this means?
Those are compiler generated classes used by lambda expressions to capture free variables in the lambda expression.
http://msdn.microsoft.com/en-us/library/bb981314%28v=vs.80%29.aspx