TypeBuilder.GetCustomAttributes 方法

定義

傳回為這個類型定義的自訂屬性。Returns the custom attributes defined for this type.

多載

GetCustomAttributes(Boolean)

傳回為這個類型定義的所有自訂屬性。Returns all the custom attributes defined for this type.

GetCustomAttributes(Type, Boolean)

傳回可指派給指定類型之目前類型的所有自訂屬性。Returns all the custom attributes of the current type that are assignable to a specified type.

GetCustomAttributes(Boolean)

傳回為這個類型定義的所有自訂屬性。Returns all the custom attributes defined for this type.

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

指定是否要搜尋這個成員的繼承鏈結以尋找屬性。Specifies whether to search this member's inheritance chain to find the attributes.

傳回

Object[]

傳回代表這個類型的所有自訂屬性的物件陣列。Returns an array of objects representing all the custom attributes of this type.

例外狀況

這個方法目前不支援不完整的類型。This method is not currently supported for incomplete types. 使用 GetType() 擷取類型,並在傳回的 Type 上呼叫 GetCustomAttributes(Boolean)Retrieve the type using GetType() and call GetCustomAttributes(Boolean) on the returned Type.

適用於

GetCustomAttributes(Type, Boolean)

傳回可指派給指定類型之目前類型的所有自訂屬性。Returns all the custom attributes of the current type that are assignable to a specified type.

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

要搜尋的屬性類型。The type of attribute to search for. 只會傳回可指派給這種類型的屬性。Only attributes that are assignable to this type are returned.

inherit
Boolean

指定是否要搜尋這個成員的繼承鏈結以尋找屬性。Specifies whether to search this member's inheritance chain to find the attributes.

傳回

Object[]

在目前類型上定義的自訂屬性陣列。An array of custom attributes defined on the current type.

例外狀況

這個方法目前不支援不完整的類型。This method is not currently supported for incomplete types. 使用 GetType() 擷取類型,並在傳回的 Type 上呼叫 GetCustomAttributes(Boolean)Retrieve the type using GetType() and call GetCustomAttributes(Boolean) on the returned Type.

attributeTypenullattributeType is null.

類型必須是基礎執行階段系統所提供的類型。The type must be a type provided by the underlying runtime system.

適用於