Retrieves all public and non-public methods defined on the current Type, including those inherited from base classes and implemented interfaces.
The GetMethods
method returns an array of MethodInfo
objects, each representing a method. You can then use these objects to inspect and invoke the methods.
public MethodInfo[] GetMethods(
BindingFlags bindingAttr
);
The syntax shown is for the C# language.
bindingAttr
BindingFlags
constants that specify how to search for members.
This parameter can include flags like Public
, NonPublic
, Instance
, Static
, etc.
An array of MethodInfo
objects representing all public and non-public methods defined on the current Type.
Returns an empty array if no methods match the specified binding flags.
This method does not throw exceptions.
The following example retrieves all public instance methods defined on the String
class.
This example demonstrates how to retrieve both public and non-public instance methods.