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

属性值

此属性的特性。

实现

注解

属性 Attributes 返回与此 PropertyInfo 对象表示的属性关联的属性。 这些属性主要是编译器在创建属性时应用的修饰符;它们指示属性是否为默认属性、 SpecialName 属性等。 请注意,对于在 .NET Framework 类库中的类型中找到的几乎所有属性,属性PropertyAttributes.NoneAttributes值为 。

提示

在大多数情况下,你可能想要检索与属性关联的自定义属性。 为此,请检索 属性的值 CustomAttributes ,或调用 方法的重载 GetCustomAttributes 之一。

Attributes获取 属性:

  1. 获取一个 Type 对象,该对象表示属性所属的类型。

  2. PropertyInfo通过调用 方法的Type.GetProperty重载获取 对象。

  3. 从 属性检索属性的属性 Attributes

可以通过调用 方法的重载 DefineProperty 并为 参数提供值 attributes ,为使用反射发出动态创建的类型定义属性的属性。

适用于

另请参阅