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?

Recommended Answers

All 3 Replies

if MethodInfo instance.Property = ? get else don't get

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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.