Enumerating sub-namespaces

E

Ed Curren

Hello all,
I want to enumerate the namespaces under a given
namespace. For example I would like to submit the
namespace of System and get CodeDOM, Collections,
ComponentModel, Configuration, etc. Can someone clue me
in on how to do this?

Thanks All
Ed
 
A

Alvin Bruney

Hello all,
I want to read MSDN. For example I would like to ask a stupid question
that is already answered in there etc... Can someone hit me with a
cluestick?

Thanks all,
 
J

Jon Skeet [C# MVP]

Ed Curren said:
I want to enumerate the namespaces under a given
namespace. For example I would like to submit the
namespace of System and get CodeDOM, Collections,
ComponentModel, Configuration, etc. Can someone clue me
in on how to do this?

You would need to load the assemblies you wanted to examine, and then
go through each type in each of the assemblies, and see if its
namespace matched what you wanted it to.
 
G

Guest

Hi Jon,
Thanks for the reply. This was the approach I had
taken before posting the question, but it did not provide
the NameSpaces, but rather the data types that were a
part of the given assembly. Below is a code snippet of
what I have been doing.

Assembly assemblyData = Assembly.GetAssembly(typeof
(Object));

Type[] types = assemblyData.GetTypes();

foreach (Type type in types) {

if (type.IsPublic) {

if ((!type.Name.StartsWith("_"))
&& (type.Namespace == "System"))

memberList.Add(new
IntelliPromptMemberListItem(type.Name, 0));

}

}
 

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

Similar Threads


Top