DynamicMethod.GetCustomAttributes 方法

定義

傳回套用至方法的自訂屬性。

多載

GetCustomAttributes(Boolean)

傳回為這個方法定義的所有自訂屬性。

GetCustomAttributes(Type, Boolean)

傳回已套用至該方法之指定類型的自訂屬性。

GetCustomAttributes(Boolean)

來源:
DynamicMethod.cs
來源:
DynamicMethod.cs
來源:
DynamicMethod.cs

傳回為這個方法定義的所有自訂屬性。

public:
 override cli::array <System::Object ^> ^ GetCustomAttributes(bool inherit);
public override object[] GetCustomAttributes (bool inherit);
override this.GetCustomAttributes : bool -> obj[]
Public Overrides Function GetCustomAttributes (inherit As Boolean) As Object()

參數

inherit
Boolean

true 表示要搜尋方法的繼承鏈結以尋找自訂屬性;false 表示只會檢查目前的方法。

傳回

Object[]

代表這個方法所有自訂屬性的物件陣列。

備註

針對動態方法,針對 trueinherit 指定 不會有任何作用,因為方法未在型別中宣告。

注意

動態方法目前不支援自定義屬性。 傳回的唯一屬性是 MethodImplAttribute;您可以使用 方法更輕鬆地取得方法實作 GetMethodImplementationFlags 旗標。

另請參閱

適用於

GetCustomAttributes(Type, Boolean)

來源:
DynamicMethod.cs
來源:
DynamicMethod.cs
來源:
DynamicMethod.cs

傳回已套用至該方法之指定類型的自訂屬性。

public:
 override cli::array <System::Object ^> ^ GetCustomAttributes(Type ^ attributeType, bool inherit);
public override object[] GetCustomAttributes (Type attributeType, bool inherit);
override this.GetCustomAttributes : Type * bool -> obj[]
Public Overrides Function GetCustomAttributes (attributeType As Type, inherit As Boolean) As Object()

參數

attributeType
Type

Type,代表要傳回的自訂屬性類型。

inherit
Boolean

true 表示要搜尋方法的繼承鏈結以尋找自訂屬性;false 表示只會檢查目前的方法。

傳回

Object[]

代表此方法屬性的物件陣列之類型為 attributeType 或衍生自類型 attributeType

例外狀況

attributeTypenull

備註

針對動態方法,針對 trueinherit 指定 不會有任何作用,因為方法未在型別中宣告。

注意

動態方法目前不支援自定義屬性。 傳回的唯一屬性是 MethodImplAttribute;您可以使用 方法更輕鬆地取得方法實作 GetMethodImplementationFlags 旗標。

另請參閱

適用於