Share via


PropertyInfo.Attributes 屬性

定義

取得這個屬性 (Property) 的屬性 (Attribute)。

public:
 abstract property System::Reflection::PropertyAttributes Attributes { System::Reflection::PropertyAttributes get(); };
public abstract System.Reflection.PropertyAttributes Attributes { get; }
member this.Attributes : System.Reflection.PropertyAttributes
Public MustOverride ReadOnly Property Attributes As PropertyAttributes

屬性值

這個屬性 (Property) 的屬性 (Attribute)。

實作

備註

屬性會 Attributes 傳回與這個 PropertyInfo 物件所表示之屬性相關聯的屬性。 屬性主要是在建立屬性時由編譯程式套用的修飾詞;它們會指出屬性是否為預設屬性、 SpecialName 屬性等等。 請注意,對於在 .NET Framework 類別庫中類型中找到的所有屬性,屬性的值AttributesPropertyAttributes.None

提示

在大部分情況下,您可能想要擷取與屬性相關聯的自定義屬性。 若要這樣做,請擷取 屬性的值 CustomAttributes ,或呼叫 方法的 GetCustomAttributes 其中一個多載。

若要取得 Attributes 屬性:

  1. Type取得物件,表示屬性所屬的類型。

  2. PropertyInfo呼叫 方法的多Type.GetProperty載來取得 物件。

  3. Attributes 屬性擷取屬性的屬性。

您可以藉由呼叫 方法的多 DefineProperty 載並提供 自變數的值 attributes ,為動態建立的類型定義屬性的屬性。

適用於

另請參閱