Possible Duplicate:
C#: List All Classes in Assembly
How I can get all class names in specific project using reflection?
Edit 1)
Is it possible to distinguish between programmer defined class and built-in classes?
Possible Duplicate:
C#: List All Classes in Assembly
How I can get all class names in specific project using reflection?
Is it possible to distinguish between programmer defined class and built-in classes?
You can use Type[] types = Assembly.GetExecutingAssembly().GetTypes()
to get all types in the assembly that contains this line of code; the Type
class has the Name
property.
The two previous posters are correct. However, if you wanted a list of all referenced assemblies and their types, you could do:
var referencedAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
var referencedTypes = referencedAssemblies.SelectMany(x => Assembly.Load(x.FullName).GetTypes());
This would give a list of all Types from the core libraries, third-parties etc which are referenced and used, if you are not using an assembly but have it referenced it wouldn't list its types.
It isn't greatly useful as it lists thousands of types from System and System.Core etc, but i'm not entirely sure what you're trying to achieve, so it may be a start.