ICustomAttributeProvider.GetCustomAttributes ICustomAttributeProvider.GetCustomAttributes ICustomAttributeProvider.GetCustomAttributes ICustomAttributeProvider.GetCustomAttributes Method

定義

傳回在這個成員上定義的自訂屬性。Returns custom attributes defined on this member.

多載

GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean)

傳回這個成員中定義的所有自訂屬性的陣列 (但具名屬性除外),如果沒有自訂屬性,則傳回空陣列。Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.

GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean)

傳回這個成員中定義的自訂屬性陣列 (依類型識別),如果沒有該類型的自訂屬性,則傳回空陣列。Returns an array of custom attributes defined on this member, identified by type, or an empty array if there are no custom attributes of that type.

GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean)

傳回這個成員中定義的所有自訂屬性的陣列 (但具名屬性除外),如果沒有自訂屬性,則傳回空陣列。Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.

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 Boolean Boolean Boolean

true 時,請查閱繼承自訂屬性的階層鏈結。When true, look up the hierarchy chain for the inherited custom attribute.

傳回

Object[]

代表自訂屬性的物件陣列或空陣列。An array of Objects representing custom attributes, or an empty array.

例外狀況

無法載入自訂屬性類型。The custom attribute type cannot be loaded.

這個成員中定義了類別 attributeType 的多個屬性。There is more than one attribute of type attributeType defined on this member.

備註

ICustomAttributeProvider.GetCustomAttributesPropertyInfo EventInfo 參數不true是流覽類型階層時, 在或上呼叫。 GetCustomAttributes inheritCalling ICustomAttributeProvider.GetCustomAttributes on PropertyInfo or EventInfo when the inherit parameter of GetCustomAttributes is true does not walk the type hierarchy. 使用System.Attribute繼承自訂屬性。Use System.Attribute to inherit custom attributes.

這個方法只會傳回在非繼承成員上直接定義的自訂屬性。This method returns custom attributes defined directly on a non-inherited member only.

GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean)

傳回這個成員中定義的自訂屬性陣列 (依類型識別),如果沒有該類型的自訂屬性,則傳回空陣列。Returns an array of custom attributes defined on this member, identified by type, or an empty array if there are no custom attributes of that type.

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 Type Type Type

自訂屬性的類型。The type of the custom attributes.

inherit
Boolean Boolean Boolean Boolean

true 時,請查閱繼承自訂屬性的階層鏈結。When true, look up the hierarchy chain for the inherited custom attribute.

傳回

Object[]

代表自訂屬性的物件陣列或空陣列。An array of Objects representing custom attributes, or an empty array.

例外狀況

無法載入自訂屬性類型。The custom attribute type cannot be loaded.

備註

如果attributeType是基類或介面, 這個方法會傳回該類型的任何實作為。If attributeType is a base class or interface, this method returns any implementation of that type.

這個方法只會傳回在非繼承成員上直接定義的自訂屬性。This method returns custom attributes defined directly on a non-inherited member only.

ICustomAttributeProvider.GetCustomAttributesPropertyInfo EventInfo 參數不true是流覽類型階層時, 在或上呼叫。 GetCustomAttributes inheritCalling ICustomAttributeProvider.GetCustomAttributes on PropertyInfo or EventInfo when the inherit parameter of GetCustomAttributes is true does not walk the type hierarchy. 使用System.Attribute繼承自訂屬性。Use System.Attribute to inherit custom attributes.

適用於