MemberInfo.GetCustomAttributesData 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回 CustomAttributeData 物件的清單,表示已套用至目標成員之屬性的資料。
public:
virtual System::Collections::Generic::IList<System::Reflection::CustomAttributeData ^> ^ GetCustomAttributesData();
C#
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)
CustomAttributeData 物件的泛型清單,表示已套用至目標成員之屬性的相關資料。
使用這個方法可檢查僅限反映內容中程式代碼的自定義屬性,在自定義屬性本身定義於僅反映內容的程式代碼中。 這類Attribute.GetCustomAttributesMemberInfo.GetCustomAttributes方法不能在這類情況下使用,因為它們會建立屬性的實例。 無法執行僅限反映內容中的程序代碼。 如需詳細資訊和範例程式代碼,請參閱 CustomAttributeData 類別。
這個方法會取得類型、巢狀類型和型別成員的System.Reflection自訂屬性數據,因為 Type 命名空間中的 類別和類別代表類型成員全都衍生自 MemberInfo。
產品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |