System.Reflection.PropertyInfo
Represents a property of a type and provides mechanisms for obtaining its metadata and accessing it. This class cannot be inherited.
namespace System.Reflection
public sealed class PropertyInfo : MemberInfo
public sealed class PropertyInfo : MemberInfo
Remarks
Use the methods of this class to get information about a property, such as its name, type, declaring type, and attributes. Use the GetValue
and SetValue
methods to get and set the value of the property for a specific object.
The PropertyInfo
class can represent indexed properties as well. You can check if a property is indexed by calling the GetAccessors
method and examining the parameters.
Properties
Name | Description |
---|---|
CanRead | Gets a value indicating whether this property can be read. |
CanWrite | Gets a value indicating whether this property can be written. |
IsSpecialName | Gets a value indicating whether the name of this property is the special name. |
MemberType | Gets the metadata token that is the language token for the current member. |
Name | Gets the name of the current member. |
DeclaringType | Gets the Type that declares the current member. |
ReflectedType | Gets the Type that was used for the reflection. |
PropertyType | Gets the Type of the property. |
Methods
Name | Description |
---|---|
GetAccessors(bool nonPublic) | Returns an array of MethodInfo objects that represent the public or non-public accessors of the property. |
GetValue(object obj) | Gets the value of the property for the given object. |
GetValue(object obj, object[] index) | Gets the value of the property for the given object with the specified index values for indexed properties. |
SetValue(object obj, object value) | Sets the value of the property for the given object. |
SetValue(object obj, object value, object[] index) | Sets the value of the property for the given object with the specified index values for indexed properties. |
GetCustomAttributes(bool inherit) | When overridden in a derived class, returns an array of the custom attributes applied to this member and, optionally, attributes applied to its derived members. |