Skip to main content
.NET Framework Class Library
MethodInfo Class

Discovers the attributes of a method and provides access to method metadata.

Namespace:   System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
Syntax
<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_0%]> _
<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_1%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_2%].None)> _
<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_3%](True)> _
<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_4%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_5%].InheritanceDemand, Name := "FullTrust")> _
Public MustInherit Class MethodInfo _
	Inherits [%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_6%] _
	Implements [%$TOPIC/1wa35kh5_en-us_VS_110_2_0_0_0_7%]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_0%]]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_1%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_2%].None)]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_3%](true)]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_4%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_5%].InheritanceDemand, Name = "FullTrust")]
public abstract class MethodInfo : [%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_6%], 
	[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_1_0_7%]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_0%]]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_1%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_2%]::None)]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_3%](true)]
[[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_4%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_5%]::InheritanceDemand, Name = L"FullTrust")]
public ref class MethodInfo abstract : public [%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_6%], 
	[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_2_0_7%]
[<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_0%]>]
[<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_1%]>]
[<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_2%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_3%].None)>]
[<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_4%](true)>]
[<[%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_5%]([%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_6%].InheritanceDemand, Name = "FullTrust")>]
type MethodInfo =  
    class 
        inherit [%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_7%] 
        interface [%$TOPIC/1wa35kh5_en-us_VS_110_2_0_3_0_8%] 
    end

The MethodInfo type exposes the following members.

Constructors
  NameDescription
Protected method Supported by the XNA Framework MethodInfoInitializes a new instance of the MethodInfo class.
Top
Properties
  NameDescription
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps AttributesGets the attributes associated with this method. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps CallingConventionGets a value indicating the calling conventions for this method. (Inherited from MethodBase.)
Public property Supported by the XNA Framework ContainsGenericParametersGets a value indicating whether the generic method contains unassigned generic type parameters. (Inherited from MethodBase.)

In XNA Framework, this member is overridden by ContainsGenericParameters.
Public property Supported in .NET for Windows Store apps CustomAttributesGets a collection that contains this member's custom attributes. (Inherited from MemberInfo.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps DeclaringTypeGets the class that declares this member. (Inherited from MemberInfo.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsAbstractGets a value indicating whether the method is abstract. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsAssemblyGets a value indicating whether the potential visibility of this method or constructor is described by MethodAttributesAssembly; that is, the method or constructor is visible at most to other types in the same assembly, and is not visible to derived types outside the assembly. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsConstructorGets a value indicating whether the method is a constructor. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsFamilyGets a value indicating whether the visibility of this method or constructor is described by MethodAttributesFamily; that is, the method or constructor is visible only within its class and derived classes. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsFamilyAndAssemblyGets a value indicating whether the visibility of this method or constructor is described by MethodAttributesFamANDAssem; that is, the method or constructor can be called by derived classes, but only if they are in the same assembly. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsFamilyOrAssemblyGets a value indicating whether the potential visibility of this method or constructor is described by MethodAttributesFamORAssem; that is, the method or constructor can be called by derived classes wherever they are, and by classes in the same assembly. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsFinalGets a value indicating whether this method is final. (Inherited from MethodBase.)
Public property Supported by the XNA Framework IsGenericMethodGets a value indicating whether the method is generic. (Inherited from MethodBase.)

In XNA Framework, this member is overridden by IsGenericMethod.
Public property Supported by the XNA Framework IsGenericMethodDefinitionGets a value indicating whether the method is a generic method definition. (Inherited from MethodBase.)

In XNA Framework, this member is overridden by IsGenericMethodDefinition.
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsHideBySigGets a value indicating whether only a member of the same kind with exactly the same signature is hidden in the derived class. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsPrivateGets a value indicating whether this member is private. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsPublicGets a value indicating whether this is a public method. (Inherited from MethodBase.)
Public property IsSecurityCriticalGets a value that indicates whether the current method or constructor is security-critical or security-safe-critical at the current trust level, and therefore can perform critical operations. (Inherited from MethodBase.)
Public property IsSecuritySafeCriticalGets a value that indicates whether the current method or constructor is security-safe-critical at the current trust level; that is, whether it can perform critical operations and can be accessed by transparent code. (Inherited from MethodBase.)
Public property IsSecurityTransparentGets a value that indicates whether the current method or constructor is transparent at the current trust level, and therefore cannot perform critical operations. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsSpecialNameGets a value indicating whether this method has a special name. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsStaticGets a value indicating whether the method is static. (Inherited from MethodBase.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps IsVirtualGets a value indicating whether the method is virtual. (Inherited from MethodBase.)
Public property Supported by the XNA Framework MemberTypeGets a MemberTypes value indicating that this member is a method. (Overrides MemberInfoMemberType.)
Public property MetadataTokenGets a value that identifies a metadata element. (Inherited from MemberInfo.)
Public property Supported by the XNA Framework Supported by Portable Class Library MethodHandleGets a handle to the internal metadata representation of a method. (Inherited from MethodBase.)
Public property Supported in .NET for Windows Store apps MethodImplementationFlagsGets the MethodImplAttributes flags that specify the attributes of a method implementation. (Inherited from MethodBase.)
Public property Supported in .NET for Windows Store apps ModuleGets the module in which the type that declares the member represented by the current MemberInfo is defined. (Inherited from MemberInfo.)
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps NameGets the name of the current member. (Inherited from MemberInfo.)
Public property Supported by the XNA Framework Supported by Portable Class Library ReflectedTypeGets the class object that was used to obtain this instance of MemberInfo. (Inherited from MemberInfo.)
Public property Supported by Portable Class Library Supported in .NET for Windows Store apps ReturnParameterGets a ParameterInfo object that contains information about the return type of the method, such as whether the return type has custom modifiers.
Public property Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ReturnTypeGets the return type of this method.
Public property Supported by the XNA Framework ReturnTypeCustomAttributesGets the custom attributes for the return type.
Top
Methods
  NameDescription
Public method Supported in .NET for Windows Store apps CreateDelegate(Type)Creates a delegate of the specified type from this method.
Public method Supported in .NET for Windows Store apps CreateDelegate(Type, Object)Creates a delegate of the specified type with the specified target from this method.
Public method Supported by the XNA Framework Supported by Portable Class Library EqualsReturns a value that indicates whether this instance is equal to a specified object. (Overrides MethodBaseEquals(Object).)

In XNA Framework 3.0, this member is inherited from Object Equals(Object).


In Portable Class Library Portable Class Library, this member is inherited from Object Equals(Object).
Protected method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by the XNA Framework Supported by Portable Class Library GetBaseDefinitionWhen 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.
Public method Supported by the XNA Framework Supported by Portable Class Library GetCustomAttributes(Boolean)When overridden in a derived class, returns an array of all custom attributes applied to this member. (Inherited from MemberInfo.)
Public method Supported by the XNA Framework Supported by Portable Class Library GetCustomAttributes(Type, Boolean)When overridden in a derived class, returns an array of custom attributes applied to this member and identified by Type. (Inherited from MemberInfo.)
Public method GetCustomAttributesDataReturns a list of CustomAttributeData objects representing data about the attributes that have been applied to the target member. (Inherited from MemberInfo.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetGenericArgumentsReturns an array of Type objects that represent the type arguments of a generic method or the type parameters of a generic method definition. (Overrides MethodBaseGetGenericArguments.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetGenericMethodDefinitionReturns a MethodInfo object that represents a generic method definition from which the current method can be constructed.
Public method Supported by the XNA Framework Supported by Portable Class Library GetHashCodeReturns the hash code for this instance. (Overrides MethodBaseGetHashCode.)

In XNA Framework 3.0, this member is inherited from Object GetHashCode.


In Portable Class Library Portable Class Library, this member is inherited from Object GetHashCode.
Public method GetMethodBodyWhen overridden in a derived class, gets a MethodBody object that provides access to the MSIL stream, local variables, and exceptions for the current method. (Inherited from MethodBase.)
Public method GetMethodImplementationFlagsWhen overridden in a derived class, returns the MethodImplAttributes flags. (Inherited from MethodBase.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetParametersWhen overridden in a derived class, gets the parameters of the specified method or constructor. (Inherited from MethodBase.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps Invoke(Object, Object)Invokes the method or constructor represented by the current instance, using the specified parameters. (Inherited from MethodBase.)
Public method Supported by the XNA Framework Invoke(Object, BindingFlags, Binder, Object, CultureInfo)When overridden in a derived class, invokes the reflected method or constructor with the given parameters. (Inherited from MethodBase.)
Public method Supported by the XNA Framework Supported by Portable Class Library IsDefinedWhen overridden in a derived class, indicates whether one or more attributes of the specified type or of its derived types is applied to this member. (Inherited from MemberInfo.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps MakeGenericMethodSubstitutes 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.
Protected method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Operators
  NameDescription
Public operator Static member EqualityIndicates whether two MethodInfo objects are equal.
Public operator Static member InequalityIndicates whether two MethodInfo objects are not equal.
Top
Extension Methods
  NameDescription
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttribute(Type)Overloaded. Retrieves a custom attribute of a specified type that is applied to a specified member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttribute(Type, Boolean)Overloaded. Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributeTOverloaded. Retrieves a custom attribute of a specified type that is applied to a specified member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributeT(Boolean)Overloaded. Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributesOverloaded. Retrieves a collection of custom attributes that are applied to a specified member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributes(Boolean)Overloaded. Retrieves a collection of custom attributes that are applied to a specified member, and optionally inspects the ancestors of that member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributes(Type)Overloaded. Retrieves a collection of custom attributes of a specified type that are applied to a specified member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributes(Type, Boolean)Overloaded. Retrieves a collection of custom attributes of a specified type that are applied to a specified member, and optionally inspects the ancestors of that member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributesTOverloaded. Retrieves a collection of custom attributes of a specified type that are applied to a specified member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetCustomAttributesT(Boolean)Overloaded. Retrieves a collection of custom attributes of a specified type that are applied to a specified member, and optionally inspects the ancestors of that member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps GetRuntimeBaseDefinitionRetrieves an object that represents the specified method on the direct or indirect base class where the method was first declared. (Defined by RuntimeReflectionExtensions.)
Public Extension Method Supported in .NET for Windows Store apps IsDefined(Type)Overloaded. Indicates whether custom attributes of a specified type are applied to a specified member. (Defined by CustomAttributeExtensions.)
Public Extension Method Supported in .NET for Windows Store apps IsDefined(Type, Boolean)Overloaded. Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors. (Defined by CustomAttributeExtensions.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private method _MemberInfoGetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from MemberInfo.)
Explicit interface implemetation Private method _MemberInfoGetTypeGets a Type object representing the MemberInfo class. (Inherited from MemberInfo.)
Explicit interface implemetation Private method _MemberInfoGetTypeInfoRetrieves the type information for an object, which can then be used to get the type information for an interface. (Inherited from MemberInfo.)
Explicit interface implemetation Private method _MemberInfoGetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from MemberInfo.)
Explicit interface implemetation Private method _MemberInfoInvokeProvides access to properties and methods exposed by an object. (Inherited from MemberInfo.)
Explicit interface implemetation Private method _MethodBaseGetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from MethodBase.)
Explicit interface implemetation Private method _MethodBaseGetTypeFor a description of this member, see _MethodBaseGetType. (Inherited from MethodBase.)
Explicit interface implemetation Private method _MethodBaseGetTypeInfoRetrieves the type information for an object, which can then be used to get the type information for an interface. (Inherited from MethodBase.)
Explicit interface implemetation Private method _MethodBaseGetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from MethodBase.)
Explicit interface implemetation Private method _MethodBaseInvokeProvides access to properties and methods exposed by an object. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsAbstractFor a description of this member, see _MethodBaseIsAbstract. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsAssemblyFor a description of this member, see _MethodBaseIsAssembly. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsConstructorFor a description of this member, see _MethodBaseIsConstructor. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsFamilyFor a description of this member, see _MethodBaseIsFamily. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsFamilyAndAssemblyFor a description of this member, see _MethodBaseIsFamilyAndAssembly. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsFamilyOrAssemblyFor a description of this member, see _MethodBaseIsFamilyOrAssembly. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsFinalFor a description of this member, see _MethodBaseIsFinal. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsHideBySigFor a description of this member, see _MethodBaseIsHideBySig. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsPrivateFor a description of this member, see _MethodBaseIsPrivate. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsPublicFor a description of this member, see _MethodBaseIsPublic. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsSpecialNameFor a description of this member, see _MethodBaseIsSpecialName. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsStaticFor a description of this member, see _MethodBaseIsStatic. (Inherited from MethodBase.)
Explicit interface implemetation Private property _MethodBaseIsVirtualFor a description of this member, see _MethodBaseIsVirtual. (Inherited from MethodBase.)
Explicit interface implemetation Private method _MethodInfoGetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers.
Explicit interface implemetation Private method _MethodInfoGetTypeProvides access to the GetType method from COM.
Explicit interface implemetation Private method _MethodInfoGetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface.
Explicit interface implemetation Private method _MethodInfoGetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1).
Explicit interface implemetation Private method _MethodInfoInvokeProvides access to properties and methods exposed by an object.
Top
Remarks

Instances of MethodInfo are obtained by calling the GetMethods or GetMethod method of a Type object or of an object that derives from Type, or by calling the MakeGenericMethod method of a MethodInfo 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.

Notes to Inheritors

When you inherit from MethodInfo, you must override MethodInfoGetBaseDefinition, MethodInfoReturnType, MethodInfoReturnTypeCustomAttributes, MethodBaseGetParameters, MethodBaseGetMethodImplementationFlags, MethodBaseMethodHandle, MethodBaseAttributes, MethodBaseInvoke, MemberInfoName, MemberInfoMemberType, MemberInfoDeclaringType, MemberInfoReflectedType, MemberInfoGetCustomAttributes, MemberInfoGetCustomAttributes, and MemberInfoIsDefined.

Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8
.NET Framework Security
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety

This type is thread safe.