ICustomAttributeProvider.GetCustomAttributes 方法

定義

傳回在這個成員上定義的自訂屬性。

多載

GetCustomAttributes(Boolean)

傳回這個成員中定義的所有自訂屬性的陣列 (但具名屬性除外),如果沒有自訂屬性,則傳回空陣列。

GetCustomAttributes(Type, Boolean)

傳回這個成員中定義的自訂屬性陣列 (依類型識別),如果沒有該類型的自訂屬性,則傳回空陣列。

GetCustomAttributes(Boolean)

傳回這個成員中定義的所有自訂屬性的陣列 (但具名屬性除外),如果沒有自訂屬性,則傳回空陣列。

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

參數

inherit
Boolean

true 時,請查閱繼承自訂屬性的階層鏈結。

傳回

Object[]

代表自訂屬性的物件陣列或空陣列。

例外狀況

無法載入自訂屬性類型。

這個成員中定義了類別 attributeType 的多個屬性。

備註

ICustomAttributeProvider.GetCustomAttributesPropertyInfoGetCustomAttributestrue 數未執行類型階層時inherit,呼叫 或 EventInfo 。 使用 System.Attribute 繼承自定義屬性。

這個方法只會傳回直接在非繼承成員上定義的自定義屬性。

適用於

GetCustomAttributes(Type, Boolean)

傳回這個成員中定義的自訂屬性陣列 (依類型識別),如果沒有該類型的自訂屬性,則傳回空陣列。

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

參數

attributeType
Type

自訂屬性的類型。

inherit
Boolean

true 時,請查閱繼承自訂屬性的階層鏈結。

傳回

Object[]

代表自訂屬性的物件陣列或空陣列。

例外狀況

無法載入自訂屬性類型。

attributeTypenull

備註

如果 attributeType 是基類或介面,這個方法會傳回該型別的任何實作。

這個方法只會傳回直接在非繼承成員上定義的自定義屬性。

ICustomAttributeProvider.GetCustomAttributesPropertyInfoGetCustomAttributestrue 數未執行類型階層時inherit,呼叫 或 EventInfo 。 使用 System.Attribute 繼承自定義屬性。

適用於