MethodInfo 类

发现方法的属性 (Attribute) 并提供对方法元数据的访问。

**命名空间:**System.Reflection
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.None)> _
Public MustInherit Class MethodInfo
    Inherits MethodBase
    Implements _MethodInfo
用法
Dim instance As MethodInfo
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.None)] 
public abstract class MethodInfo : MethodBase, _MethodInfo
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::None)] 
public ref class MethodInfo abstract : public MethodBase, _MethodInfo
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.None) */ 
public abstract class MethodInfo extends MethodBase implements _MethodInfo
SerializableAttribute 
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.None) 
public abstract class MethodInfo extends MethodBase implements _MethodInfo

备注

MethodInfo 的实例可以通过调用 GetMethods 或者 Type 对象或派生自 Type 的对象的 GetMethod 方法来获取,还可以通过调用表示泛型方法定义的 MethodInfoMakeGenericMethod 方法来获取。

有关特定于泛型方法的术语的固定条件列表,请参见 IsGenericMethod 属性。有关泛型反射中使用的其他术语的固定条件列表,请参见 IsGenericType 属性。

给继承者的说明 当从 MethodInfo 继承时,必须重写以下成员:MethodInfo.GetBaseDefinitionMethodInfo.ReturnTypeMethodInfo.ReturnTypeCustomAttributesMethodBase.GetParametersMethodBase.GetMethodImplementationFlagsMethodBase.MethodHandleMethodBase.AttributesMethodBase.InvokeMemberInfo.NameMemberInfo.MemberTypeMemberInfo.DeclaringTypeMemberInfo.ReflectedTypeMemberInfo.GetCustomAttributesMemberInfo.GetCustomAttributesMemberInfo.IsDefined

继承层次结构

System.Object
   System.Reflection.MemberInfo
     System.Reflection.MethodBase
      System.Reflection.MethodInfo
         Microsoft.JScript.JSMethod
         Microsoft.JScript.JSMethodInfo
         System.Reflection.Emit.DynamicMethod
         System.Reflection.Emit.MethodBuilder

线程安全

该类型对于多线程操作是安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

MethodInfo 成员
System.Reflection 命名空间
System.Type.GetMethods
System.Type.GetMethod
IsGenericMethod