How do I get all methods from a specific namespace?

I want all class name Method-ClassName from namespace

how do i have system.windows.Forms

wehen in visual studio we install system.windows.Forms. it will suggest a field with all associated method, class, enum extra

I need to get the same thing, how can I do it in C #

0


source to share


2 answers


For starters, there are no methods in the namespace - only types.

To get all types from one namespace in a specific 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 distributed across multiple assemblies.

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

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

+5


source


This functionality is called "reflection".



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

0


source







All Articles