views:

105

answers:

2

hello

I want all the Method-ClassName from namespace

like i have system.windows.Forms

wehen in visual studio we rigt system.windows.Forms. it will suggest box of all the related method,class,enum extra

i need to fetch the same ,how can i do that in C#

Thanks

+4  A: 

For a start, there are no methods in a namespace - only types.

To get all the types from one namespace within a particular assembly, you can use (assuming .NET 3.5 for the LINQ bit) Assembly.GetTypes:

var types = assembly.GetTypes().Where(type => type.Namespace == desiredNamespace);

Types can be spread across multiple assemblies, however.

Once you've got a type, you can use Type.GetMethods to retrieve the methods available. Use appropriate BindingFlags to get static/instance, public/non-public methods etc.

If this doesn't help, please clarify the question.

Jon Skeet
A: 

This kind of functionality is called "reflection".

http://www.codersource.net/published/view/291/reflection_in.aspx for example (which I found by Googling for 'reflection' and 'C#') mentions relevent .NET API methods which you invoke from C#.

ChrisW