MethodInfo
Class
Definition
Discovers the attributes of a method and provides access to method metadata.
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class MethodInfo : System.Reflection.MethodBase, System.Runtime.InteropServices._MethodInfo
- Inheritance
- Derived
- Attributes
- Implements
Inherited Members
System.Object
System.Reflection.MemberInfo
System.Reflection.MethodBase
Remarks
The MethodInfo class represents a method of a type. You can use a MethodInfo object to obtain information about the method that the object represents and to invoke the method. For example:
You can determine the method's visibility by retrieving the values of the IsFamilyAndAssembly, IsFamilyOrAssembly, IsPrivate, and IsPublic properties.
You can discover what attributes are applied to the method by retrieving the value of the Attributes property or calling the GetCustomAttributes method.
You can determine whether the method is a generic method, an open constructed generic method, or a closed constructed generic method, by retrieving the values of the IsGenericMethod and ContainsGenericParameters properties.
You can get information about the method's parameters and return type from the GetParameters method and the ReturnParameter, ReturnType, and ReturnTypeCustomAttributes properties.
You can execute a method on a class instance by calling the Invoke method.
You can instantiate a MethodInfo object that represents a constructed generic method from one that represents a generic method definition by calling the MakeGenericMethod method.
You can instantiate a MethodInfo instances by calling the Type.GetMethods or Type.GetMethod method, or by calling the MethodInfo.MakeGenericMethod method of a MethodInfo object that represents a generic method definition.
For a list of the invariant conditions for terms specific to generic methods, see the IsGenericMethod property. For a list of the invariant conditions for other terms used in generic reflection, see the IsGenericType property.
Constructors
| MethodInfo() |
Initializes a new instance of the MethodInfo class. |
Properties
| MemberType |
Gets a MemberTypes value indicating that this member is a method. |
| ReturnParameter |
Gets a ParameterInfo object that contains information about the return type of the method, such as whether the return type has custom modifiers. |
| ReturnType |
Gets the return type of this method. |
| ReturnTypeCustomAttributes |
Gets the custom attributes for the return type. |
Methods
| CreateDelegate(Type) |
Creates a delegate of the specified type from this method. |
| CreateDelegate(Type, Object) |
Creates a delegate of the specified type with the specified target from this method. |
| Equals(Object) |
Returns a value that indicates whether this instance is equal to a specified object. |
| GetBaseDefinition() |
When overridden in a derived class, returns the MethodInfo object for the method on the direct or indirect base class in which the method represented by this instance was first declared. |
| GetGenericArguments() |
Returns an array of Type objects that represent the type arguments of a generic method or the type parameters of a generic method definition. |
| GetGenericMethodDefinition() |
Returns a MethodInfo object that represents a generic method definition from which the current method can be constructed. |
| GetHashCode() |
Returns the hash code for this instance. |
| MakeGenericMethod(Type[]) |
Substitutes the elements of an array of types for the type parameters of the current generic method definition, and returns a MethodInfo object representing the resulting constructed method. |
Operators
| Equality(MethodInfo, MethodInfo) |
Indicates whether two MethodInfo objects are equal. |
| Inequality(MethodInfo, MethodInfo) |
Indicates whether two MethodInfo objects are not equal. |
Explicit Interface Implementations
| _MethodInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Maps a set of names to a corresponding set of dispatch identifiers. |
| _MethodInfo.GetType() |
Provides access to the GetType() method from COM. |
| _MethodInfo.GetTypeInfo(UInt32, UInt32, IntPtr) |
Retrieves the type information for an object, which can be used to get the type information for an interface. |
| _MethodInfo.GetTypeInfoCount(UInt32) |
Retrieves the number of type information interfaces that an object provides (either 0 or 1). |
| _MethodInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Provides access to properties and methods exposed by an object. |
Extension Methods
Thread Safety
This type is thread safe.