Determine all classes within a namespace

  • Thread starter Thread starter jw56578
  • Start date Start date
J

jw56578

Hi,
Is there a way to discover all the classes within a given namespace?
thanks
 
Hi,

I don't know if there is an easier way to do this, but the brute force way is to
list all the types in the assembly, go through each type, and use the Namespace
property of the type to compare against your target.

foreach (Type type in myAssembly.GetTypes())
{
if (type.Namespace == target)
{
...
}
}

where myAssembly is the assembly you want to check. If you only want classes,
use the Type's IsClass property as part of the check.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top