DynamicMethod.GetCustomAttributes 方法

定義

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

多載

名稱 Description
GetCustomAttributes(Boolean)

會回傳所有為該方法定義的自訂屬性。

GetCustomAttributes(Type, Boolean)

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

GetCustomAttributes(Boolean)

來源:
DynamicMethod.cs
來源:
DynamicMethod.cs
來源:
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 沒有影響,因為該方法並未以型別宣告。

Note

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

另請參閱

適用於

GetCustomAttributes(Type, Boolean)

來源:
DynamicMethod.cs
來源:
DynamicMethod.cs
來源:
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

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

inherit
Boolean

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

傳回

Object[]

一組代表方法屬性的物件陣列,這些物件的型別 attributeType 為 或源自型別 attributeType

例外狀況

attributeTypenull

備註

對於動態方法,指定 trueinherit 沒有影響,因為該方法並未以型別宣告。

Note

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

另請參閱

適用於