PropertyInfo::Attributes Property

 

Gets the attributes for this property.

Namespace:   System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

public:
property PropertyAttributes Attributes {
	virtual PropertyAttributes get() abstract;
}

Property Value

Type: System.Reflection::PropertyAttributes

The attributes of this property.

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.

System_CAPS_tipTip

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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: