MemberInfo.GetCustomAttributesData 方法

定義

傳回 CustomAttributeData 物件的清單,表示已套用至目標成員之屬性的資料。

public:
 virtual System::Collections::Generic::IList<System::Reflection::CustomAttributeData ^> ^ GetCustomAttributesData();
public virtual System.Collections.Generic.IList<System.Reflection.CustomAttributeData> GetCustomAttributesData ();
abstract member GetCustomAttributesData : unit -> System.Collections.Generic.IList<System.Reflection.CustomAttributeData>
override this.GetCustomAttributesData : unit -> System.Collections.Generic.IList<System.Reflection.CustomAttributeData>
Public Overridable Function GetCustomAttributesData () As IList(Of CustomAttributeData)

傳回

IList<CustomAttributeData>

CustomAttributeData 物件的泛型清單,表示已套用至目標成員之屬性的相關資料。

備註

在僅限反映的內容中,您可以使用這個方法來檢查程式碼的自訂屬性,以在自訂屬性本身是在載入僅限反映內容的程式碼中定義的情況。 方法(例如 Attribute.GetCustomAttributesMemberInfo.GetCustomAttributes )無法在這種情況下使用,因為它們會建立屬性的實例。 無法執行僅限反映內容中的程式碼。 如需詳細資訊和範例程式碼,請參閱 CustomAttributeData 類別。

這個方法會取得類型、嵌套型別和型別成員的自訂屬性資料,因為 Type 命名空間中代表型別成員的類別和類別 System.Reflection 都是衍生自 MemberInfo

適用於