Get only Methods with specific signature out of Type.GetMethods()

后端 未结 5 1427
梦毁少年i
梦毁少年i 2020-12-03 18:23

I want to list all methods of a type with a specific method signature.

For example, if a type has a few public methods:

public void meth1 (int i);
pu         


        
5条回答
  •  广开言路
    2020-12-03 18:49

    You'll have to inspect all MethodInfos yourself. By calling MethodInfo.GetParameters() you'll get a collection of ParameterInfo objects, which in turn have a property ParameterType.

    The same for the return type: inspect the ReturnType property of MethodInfo.

提交回复
热议问题