MethodBase 類別
定義
提供有關方法和建構函式的資訊。Provides information about methods and constructors.
public ref class MethodBase abstract : System::Reflection::MemberInfo, System::Runtime::InteropServices::_MethodBase
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class MethodBase : System.Reflection.MemberInfo, System.Runtime.InteropServices._MethodBase
type MethodBase = class
inherit MemberInfo
interface _MethodBase
Public MustInherit Class MethodBase
Inherits MemberInfo
Implements _MethodBase
- 繼承
- 衍生
- 屬性
- 實作
備註
MethodBase
是MethodInfo 和ConstructorInfo的基類。MethodBase
is the base class of MethodInfo and ConstructorInfo.
給實施者的注意事項
當您繼承自MethodBase
時,您必須覆寫下列成員GetParameters(): Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)、 GetMethodImplementationFlags()、 MethodHandle、 Attributes、 Name、 DeclaringType、 MemberType ReflectedType、、 GetCustomAttributes(Boolean) 、、 GetCustomAttributes(Type, Boolean)和。IsDefined(Type, Boolean)When you inherit from MethodBase
, you must override the following members: GetParameters(), Invoke(Object, BindingFlags, Binder, Object[], CultureInfo), GetMethodImplementationFlags(), MethodHandle, Attributes, Name, DeclaringType, MemberType, ReflectedType, GetCustomAttributes(Boolean), GetCustomAttributes(Type, Boolean), and IsDefined(Type, Boolean).
建構函式
MethodBase() |
初始化 MethodBase 類別的新執行個體。Initializes a new instance of the MethodBase class. |
屬性
Attributes |
取得與這個方法相關的屬性 (Attribute)。Gets the attributes associated with this method. |
CallingConvention |
取得值,指出這個方法的呼叫慣例。Gets a value indicating the calling conventions for this method. |
ContainsGenericParameters |
取得值,指出泛型方法是否包含未指派的泛型型別參數。Gets a value indicating whether the generic method contains unassigned generic type parameters. |
CustomAttributes |
取得包含此成員之自訂屬性的集合。Gets a collection that contains this member's custom attributes. (繼承來源 MemberInfo) |
DeclaringType |
取得宣告這個成員的類別。Gets the class that declares this member. (繼承來源 MemberInfo) |
IsAbstract |
取得值,指出方法是否為抽象。Gets a value indicating whether the method is abstract. |
IsAssembly |
取得值,指出 Assembly 是否描述此方法或建構函式 (Constructor) 的潛在可視性;亦即,最多只有相同組件 (Assembly) 中的其他型別可以看見該方法或建構函式,組件外部的衍生型別 (Derived Type) 則看不見它們。Gets a value indicating whether the potential visibility of this method or constructor is described by Assembly; 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. |
IsCollectible |
取得指出此 MemberInfo 物件是否為可回收 AssemblyLoadContext 中保存之組件一部分的值。Gets a value that indicates whether this MemberInfo object is part of an assembly held in a collectible AssemblyLoadContext. (繼承來源 MemberInfo) |
IsConstructedGenericMethod | |
IsConstructor |
取得值,指出方法是否為建構函示。Gets a value indicating whether the method is a constructor. |
IsFamily |
取得值,指出 Family 是否描述此方法或建構函式的可視性;亦即,您只能在其類別和衍生類別內看見該方法或建構函式。Gets a value indicating whether the visibility of this method or constructor is described by Family; that is, the method or constructor is visible only within its class and derived classes. |
IsFamilyAndAssembly |
取得值,指出 FamANDAssem 是否描述此方法或建構函式的可視性;亦即,只有當該方法或建構函式位於相同的組件時,衍生類別才能呼叫它們。Gets a value indicating whether the visibility of this method or constructor is described by FamANDAssem; that is, the method or constructor can be called by derived classes, but only if they are in the same assembly. |
IsFamilyOrAssembly |
取得值,指出 FamORAssem 是否描述此方法或建構函式的潛在可視性;亦即,無論該方法或建構函式位於何處,衍生類別以及相同組件中的類別都可以呼叫它們。Gets a value indicating whether the potential visibility of this method or constructor is described by FamORAssem; that is, the method or constructor can be called by derived classes wherever they are, and by classes in the same assembly. |
IsFinal |
取得值,指出這個方法是否為 |
IsGenericMethod |
取得值,指出方法是否為泛型。Gets a value indicating whether the method is generic. |
IsGenericMethodDefinition |
取得值,指出方法是否為泛型方法定義。Gets a value indicating whether the method is a generic method definition. |
IsHideBySig |
取得值,指出是否只有簽章完全一樣的同類成員隱藏於衍生類別中。Gets a value indicating whether only a member of the same kind with exactly the same signature is hidden in the derived class. |
IsPrivate |
取得值,指出這個成員是否為私用的 (Private)。Gets a value indicating whether this member is private. |
IsPublic |
取得值,指出這是否為公用的方法。Gets a value indicating whether this is a public method. |
IsSecurityCritical |
取得值,這個值表示目前方法或建構函式在目前信任層級上是否為安全性關鍵或安全性安全關鍵,因而可以執行重要的作業。Gets 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. |
IsSecuritySafeCritical |
取得值,這個值表示目前方法或建構函式在目前信任層級上是否為安全性安全關鍵,也就是說,它是否可以執行重要作業並且可供透明程式碼存取。Gets 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. |
IsSecurityTransparent |
取得值,這個值表示目前方法或建構函式在目前信任層級上是否為透明,因此不得執行重要作業。Gets a value that indicates whether the current method or constructor is transparent at the current trust level, and therefore cannot perform critical operations. |
IsSpecialName |
取得值,指出這個方法是否有特別的名稱。Gets a value indicating whether this method has a special name. |
IsStatic |
取得值指出方法是否為 |
IsVirtual |
取得值指出方法是否為 |
MemberType |
在衍生類別中覆寫時,取得 MemberTypes 值,指出成員類型︰方法、建構函式、事件等。When overridden in a derived class, gets a MemberTypes value indicating the type of the member - method, constructor, event, and so on. (繼承來源 MemberInfo) |
MetadataToken |
取得值,這個值可識別中繼資料項目。Gets a value that identifies a metadata element. (繼承來源 MemberInfo) |
MethodHandle |
取得方法內部中繼資料 (Metadata) 表示的控制代碼。Gets a handle to the internal metadata representation of a method. |
MethodImplementationFlags |
取得 MethodImplAttributes 旗標,這些旗標會指定方法實作的屬性。Gets the MethodImplAttributes flags that specify the attributes of a method implementation. |
Module |
取得用於定義型別的模組,該型別宣告以目前 MemberInfo 表示的成員。Gets the module in which the type that declares the member represented by the current MemberInfo is defined. (繼承來源 MemberInfo) |
Name |
取得目前成員的名稱。Gets the name of the current member. (繼承來源 MemberInfo) |
ReflectedType |
取得類別物件,是用來取得這個 |
方法
Equals(Object) |
傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object. |
GetCurrentMethod() |
傳回代表目前執行方法的 |
GetCustomAttributes(Boolean) |
在衍生類別中覆寫時,傳回套用至此成員之所有自訂屬性的陣列。When overridden in a derived class, returns an array of all custom attributes applied to this member. (繼承來源 MemberInfo) |
GetCustomAttributes(Type, Boolean) |
當在衍生的類別中覆寫時,會傳回套用至這個成員的自訂屬性陣列,並以 Type 識別。When overridden in a derived class, returns an array of custom attributes applied to this member and identified by Type. (繼承來源 MemberInfo) |
GetCustomAttributesData() |
傳回 CustomAttributeData 物件的清單,表示已套用至目標成員之屬性的資料。Returns a list of CustomAttributeData objects representing data about the attributes that have been applied to the target member. (繼承來源 MemberInfo) |
GetGenericArguments() |
傳回 Type 物件的陣列,這些物件表示泛型方法的型別引數,或泛型方法定義的型別參數。Returns an array of Type objects that represent the type arguments of a generic method or the type parameters of a generic method definition. |
GetHashCode() |
傳回這個執行個體的雜湊碼。Returns the hash code for this instance. |
GetMethodBody() |
在衍生類別中覆寫時,取得 MethodBody 物件,其提供對目前方法之 MSIL 資料流、區域變數和例外狀況的存取。When overridden in a derived class, gets a MethodBody object that provides access to the MSIL stream, local variables, and exceptions for the current method. |
GetMethodFromHandle(RuntimeMethodHandle) |
利用方法的內部中繼資料表示 (控制代碼) 取得方法資訊。Gets method information by using the method's internal metadata representation (handle). |
GetMethodFromHandle(RuntimeMethodHandle, RuntimeTypeHandle) |
針對指定的泛型型別,取得指定的控制代碼所表示之建構函式或方法的 MethodBase 物件。Gets a MethodBase object for the constructor or method represented by the specified handle, for the specified generic type. |
GetMethodImplementationFlags() |
在衍生類別中覆寫時,傳回 MethodImplAttributes 旗標。When overridden in a derived class, returns the MethodImplAttributes flags. |
GetParameters() |
在衍生類別中覆寫時,取得指定方法或建構函式的參數。When overridden in a derived class, gets the parameters of the specified method or constructor. |
GetType() | |
HasSameMetadataDefinitionAs(MemberInfo) | (繼承來源 MemberInfo) |
Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) |
在衍生類別中覆寫時,需使用指定的參數叫用反映的方法或建構函式。When overridden in a derived class, invokes the reflected method or constructor with the given parameters. |
Invoke(Object, Object[]) |
使用指定的參數叫用由目前執行個體代表的方法或建構函式。Invokes the method or constructor represented by the current instance, using the specified parameters. |
IsDefined(Type, Boolean) |
在衍生類別中覆寫時,表示是否已有一個或多個具有指定型別或其衍生型別的屬性套用至這個成員。When 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. (繼承來源 MemberInfo) |
MemberwiseClone() |
建立目前 Object 的淺層複製。Creates a shallow copy of the current Object. (繼承來源 Object) |
ToString() |
傳回代表目前物件的字串。Returns a string that represents the current object. (繼承來源 Object) |
運算子
Equality(MethodBase, MethodBase) |
表示兩個 MethodBase 物件是否相等。Indicates whether two MethodBase objects are equal. |
Inequality(MethodBase, MethodBase) |
表示兩個 MethodBase 物件是否不相等。Indicates whether two MethodBase objects are not equal. |
明確介面實作
_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers. (繼承來源 MemberInfo) |
_MemberInfo.GetType() |
取得 Type 物件,表示 MemberInfo 類別。Gets a Type object representing the MemberInfo class. (繼承來源 MemberInfo) |
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr) |
擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can then be used to get the type information for an interface. (繼承來源 MemberInfo) |
_MemberInfo.GetTypeInfoCount(UInt32) |
擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1). (繼承來源 MemberInfo) |
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object. (繼承來源 MemberInfo) |
_MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers. |
_MethodBase.GetType() |
如需這個成員的說明,請參閱 GetType()。For a description of this member, see GetType(). |
_MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr) |
擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can then be used to get the type information for an interface. |
_MethodBase.GetTypeInfoCount(UInt32) |
擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1). |
_MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object. |
_MethodBase.IsAbstract |
如需這個成員的說明,請參閱 IsAbstract。For a description of this member, see IsAbstract. |
_MethodBase.IsAssembly |
如需這個成員的說明,請參閱 IsAssembly。For a description of this member, see IsAssembly. |
_MethodBase.IsConstructor |
如需這個成員的說明,請參閱 IsConstructor。For a description of this member, see IsConstructor. |
_MethodBase.IsFamily |
如需這個成員的說明,請參閱 IsFamily。For a description of this member, see IsFamily. |
_MethodBase.IsFamilyAndAssembly |
如需這個成員的說明,請參閱 IsFamilyAndAssembly。For a description of this member, see IsFamilyAndAssembly. |
_MethodBase.IsFamilyOrAssembly |
如需這個成員的說明,請參閱 IsFamilyOrAssembly。For a description of this member, see IsFamilyOrAssembly. |
_MethodBase.IsFinal |
如需這個成員的說明,請參閱 IsFinal。For a description of this member, see IsFinal. |
_MethodBase.IsHideBySig |
如需這個成員的說明,請參閱 IsHideBySig。For a description of this member, see IsHideBySig. |
_MethodBase.IsPrivate |
如需這個成員的說明,請參閱 IsPrivate。For a description of this member, see IsPrivate. |
_MethodBase.IsPublic |
如需這個成員的說明,請參閱 IsPublic。For a description of this member, see IsPublic. |
_MethodBase.IsSpecialName |
如需這個成員的說明,請參閱 IsSpecialName。For a description of this member, see IsSpecialName. |
_MethodBase.IsStatic |
如需這個成員的說明,請參閱 IsStatic。For a description of this member, see IsStatic. |
_MethodBase.IsVirtual |
如需這個成員的說明,請參閱 IsVirtual。For a description of this member, see IsVirtual. |
ICustomAttributeProvider.GetCustomAttributes(Boolean) | (繼承來源 MemberInfo) |
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) | (繼承來源 MemberInfo) |
ICustomAttributeProvider.IsDefined(Type, Boolean) | (繼承來源 MemberInfo) |
擴充方法
GetCustomAttribute(MemberInfo, Type) |
擷取指定型別的自訂屬性,此屬性套用至指定成員。Retrieves a custom attribute of a specified type that is applied to a specified member. |
GetCustomAttribute(MemberInfo, Type, Boolean) |
擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member. |
GetCustomAttribute<T>(MemberInfo) |
擷取指定型別的自訂屬性,此屬性套用至指定成員。Retrieves a custom attribute of a specified type that is applied to a specified member. |
GetCustomAttribute<T>(MemberInfo, Boolean) |
擷取只訂型別的自訂屬性,此屬性套用至指定成員,並且可選擇性檢查該成員的祖系。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member. |
GetCustomAttributes(MemberInfo) |
擷取套用至指定成員的自訂屬性集合。Retrieves a collection of custom attributes that are applied to a specified member. |
GetCustomAttributes(MemberInfo, Boolean) |
擷取自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。Retrieves a collection of custom attributes that are applied to a specified member, and optionally inspects the ancestors of that member. |
GetCustomAttributes(MemberInfo, Type) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員。Retrieves a collection of custom attributes of a specified type that are applied to a specified member. |
GetCustomAttributes(MemberInfo, Type, Boolean) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。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. |
GetCustomAttributes<T>(MemberInfo) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員。Retrieves a collection of custom attributes of a specified type that are applied to a specified member. |
GetCustomAttributes<T>(MemberInfo, Boolean) |
擷取指定型別的自訂屬性集合,此集合套用至指定成員,並且可選擇性檢查該成員的祖系。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. |
IsDefined(MemberInfo, Type) |
指出是否將所指定型別的自訂屬性套用至指定的成員。Indicates whether custom attributes of a specified type are applied to a specified member. |
IsDefined(MemberInfo, Type, Boolean) |
指出指定之型別的自訂屬性是否會套用至指定的成員,以及選擇性地套用到其上階。Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors. |
GetMetadataToken(MemberInfo) |
取得指定成員的中繼資料語彙基元 (如果有)。Gets a metadata token for the given member, if available. |
HasMetadataToken(MemberInfo) |
傳回值,指出所指定成員是否有可用的中繼資料語彙基元。Returns a value that indicates whether a metadata token is available for the specified member. |
安全性
InheritanceDemand
適用於繼承者的完全信任的。for full trust for inheritors. 此類別無法由部分信任程式碼繼承。This class cannot be inherited by partially trusted code.
適用於
執行緒安全性
此型別具備執行緒安全。This type is thread safe.