Upraviť

Zdieľať cez


PropertyInfo.Attributes Property

Definition

Gets the attributes for this property.

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 Value

The attributes of this property.

Implements

Remarks

The Attributes property returns the attributes associated with the property represented by this PropertyInfo object. The attributes are primarily modifiers applied by a compiler when creating a property; they indicate whether a property is the default property, a SpecialName property, and so on. Note that, for almost all properties found in types in the .NET Framework class library, the value of the Attributes property is PropertyAttributes.None.

Tip

In most cases, you probably want to retrieve the custom attributes associated with a property. To do this, retrieve the value of the CustomAttributes property, or call one of the overloads of the GetCustomAttributes method.

To get the Attributes property:

  1. Get a Type object that represents the type to which the property belongs.

  2. Get the PropertyInfo object by calling an overload of the Type.GetProperty method.

  3. Retrieve the property's attributes from the Attributes property.

You can define the attributes of a property for a type created dynamically using reflection emit by calling an overload of the DefineProperty method and supplying a value for the attributes argument.

Applies to

See also