0

Hi I am having a slight problem with dynamically listing the methods of a selected class. The code I have written is:

private void ListMethods(ClassA aClass, ComboBox cmbMethods)
{
       Type type = typeof(Application35.ClassA);
       foreach(MethodInfo aMethod in type.GetMethods())
       {
            cmbMethods.Items.Add(aMethod.ToString());
        }
        cmbMethod.Visible = true;
}

There are a number of overloads for this method, each dealing with a different class.

The method functions, however the list box is populated with more than just the method name, it includes the return type as well, also all of the methods inherited by the class are listed.

Does anyone know how to list just the name of the method and only methods that are defined within the class and not within parent classes please?

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Ramy Mahrous
0

Thanks for the reply. Could you please explain what the

= ?

means, as have never come across it before, or have i miss read and i need to replace the ? with somthing else?

0

Yes, you should read in the MethodInfo class properties, and you'll get the solution yourself, believe me, you'll.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.