C#: List All Classes in Assembly

Alex picture Alex · Aug 22, 2009 · Viewed 103k times · Source

I'd like to output (programmatically - C#) a list of all classes in my assembly.

Any hints or sample code how to do this? Reflection?

Answer

Jon Skeet picture Jon Skeet · Aug 22, 2009

Use Assembly.GetTypes. For example:

Assembly mscorlib = typeof(string).Assembly;
foreach (Type type in mscorlib.GetTypes())
{
    Console.WriteLine(type.FullName);
}