Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Reflection.​PropertyInfo

Assembly: System.Runtime

Inheritance: object → MemberInfo → PropertyInfo

Discovers the attributes of a property and provides access to property metadata.

Properties

Attributes
Gets the attributes for this property.
public bool
CanRead
Gets a value indicating whether the property can be read.
public bool
CanWrite
Gets a value indicating whether the property can be written to.
public MethodInfo
GetMethod
Gets the <see langword="get" /> accessor for this property.
public bool
IsSpecialName
Gets a value indicating whether the property is the special name.
public MemberTypes
MemberType
Gets a <see cref="T:System.Reflection.MemberTypes" /> value indicating that this member is a property.
public Type
PropertyType
Gets the type of this property.
public MethodInfo
SetMethod
Gets the <see langword="set" /> accessor for this property.
CustomAttributes
Gets a collection that contains this member's custom attributes.
public Type
DeclaringType
Gets the class that declares this member.
public bool
IsCollectible
Gets a value that indicates whether this <see cref="T:System.Reflection.MemberInfo" /> object references one or more assemblies held in a collectible <see cref="T:System.Runtime.Loader.AssemblyLoadContext" /> .
public int
MetadataToken
Gets a value that identifies a metadata element.
public Module
Module
Gets the module in which the type that declares the member represented by the current <see cref="T:System.Reflection.MemberInfo" /> is defined.
public string
Name
Gets the name of the current member.
public Type
ReflectedType
Gets the class object that was used to obtain this instance of <see langword="MemberInfo" /> .

Methods

public bool
Equals​(object obj)
obj An object to compare with this instance, or <see langword="null" /> .
Returns <see langword="true" /> if <paramref name="obj" /> equals the type and value of this instance; otherwise, <see langword="false" /> .
Returns a value that indicates whether this instance is equal to a specified object.
public MethodInfo[]
GetAccessors​()
Returns An array of <see cref="T:System.Reflection.MethodInfo" /> objects that reflect the public <see langword="get" /> and <see langword="set" /> accessors of the property reflected by the current instance, if found; otherwise, this method returns an array with zero (0) elements.
Returns an array whose elements reflect the public <see langword="get" /> and <see langword="set" /> accessors of the property reflected by the current instance.
public MethodInfo[]
GetAccessors​(bool nonPublic)
nonPublic Indicates whether non-public methods should be returned in the returned array. <see langword="true" /> if non-public methods are to be included; otherwise, <see langword="false" /> .
Returns An array whose elements reflect the <see langword="get" /> and <see langword="set" /> accessors of the property reflected by the current instance. If <paramref name="nonPublic" /> is <see langword="true" /> , this array contains public and non-public <see langword="get" /> and <see langword="set" /> accessors. If <paramref name="nonPublic" /> is <see langword="false" /> , this array contains only public <see langword="get" /> and <see langword="set" /> accessors. If no accessors with the specified visibility are found, this method returns an array with zero (0) elements.
Returns an array whose elements reflect the public and, if specified, non-public <see langword="get" /> and <see langword="set" /> accessors of the property reflected by the current instance.
public object
GetConstantValue​()
Returns An <see cref="T:System.Object" /> that contains the literal value associated with the property. If the literal value is a class type with an element value of zero, the return value is <see langword="null" /> .
Returns a literal value associated with the property by a compiler.
public MethodInfo
GetGetMethod​()
Returns A <see langword="MethodInfo" /> object representing the public <see langword="get" /> accessor for this property, or <see langword="null" /> if the <see langword="get" /> accessor is non-public or does not exist.
Returns the public <see langword="get" /> accessor for this property.
public MethodInfo
GetGetMethod​(bool nonPublic)
nonPublic Indicates whether a non-public <see langword="get" /> accessor should be returned. <see langword="true" /> if a non-public accessor is to be returned; otherwise, <see langword="false" /> .
Returns A <see langword="MethodInfo" /> object representing the <see langword="get" /> accessor for this property, if <paramref name="nonPublic" /> is <see langword="true" /> . Returns <see langword="null" /> if <paramref name="nonPublic" /> is <see langword="false" /> and the <see langword="get" /> accessor is non-public, or if <paramref name="nonPublic" /> is <see langword="true" /> but no <see langword="get" /> accessors exist.
When overridden in a derived class, returns the public or non-public <see langword="get" /> accessor for this property.
public int
GetHashCode​()
Returns A 32-bit signed integer hash code.
Returns the hash code for this instance.
public ParameterInfo[]
GetIndexParameters​()
Returns An array of type <see langword="ParameterInfo" /> containing the parameters for the indexes. If the property is not indexed, the array has 0 (zero) elements.
When overridden in a derived class, returns an array of all the index parameters for the property.
public Type
GetModifiedPropertyType​()
Returns A modified type.
Gets the modified type of this property object.
public Type[]
GetOptionalCustomModifiers​()
Returns An array of <see cref="T:System.Type" /> objects that identify the optional custom modifiers of the current property, such as <see cref="T:System.Runtime.CompilerServices.IsConst" /> or <see cref="T:System.Runtime.CompilerServices.IsImplicitlyDereferenced" /> .
Returns an array of types representing the optional custom modifiers of the property.
public object
GetRawConstantValue​()
Returns An <see cref="T:System.Object" /> that contains the literal value associated with the property. If the literal value is a class type with an element value of zero, the return value is <see langword="null" /> .
Returns a literal value associated with the property by a compiler.
public Type[]
GetRequiredCustomModifiers​()
Returns An array of <see cref="T:System.Type" /> objects that identify the required custom modifiers of the current property, such as <see cref="T:System.Runtime.CompilerServices.IsConst" /> or <see cref="T:System.Runtime.CompilerServices.IsImplicitlyDereferenced" /> .
Returns an array of types representing the required custom modifiers of the property.
public MethodInfo
GetSetMethod​()
Returns The <see langword="MethodInfo" /> object representing the <see langword="Set" /> method for this property if the <see langword="set" /> accessor is public, or <see langword="null" /> if the <see langword="set" /> accessor is not public.
Returns the public <see langword="set" /> accessor for this property.
public MethodInfo
GetSetMethod​(bool nonPublic)
nonPublic Indicates whether the accessor should be returned if it is non-public. <see langword="true" /> if a non-public accessor is to be returned; otherwise, <see langword="false" /> .
Returns This property's <see langword="Set" /> method, or <see langword="null" /> , as shown in the following table. <list type="table"> <listheader> <term> Value</term> <description> Condition</description> </listheader> <item> <term> The <see langword="Set" /> method for this property.</term> <description> The <see langword="set" /> accessor is public, OR <paramref name="nonPublic" /> is <see langword="true" /> and the <see langword="set" /> accessor is non-public.</description> </item> <item> <term> <see langword="null" /> </term> <description> <paramref name="nonPublic" /> is <see langword="true" />, but the property is read-only, OR <paramref name="nonPublic" /> is <see langword="false" /> and the <see langword="set" /> accessor is non-public, OR there is no <see langword="set" /> accessor.</description> </item> </list>
When overridden in a derived class, returns the <see langword="set" /> accessor for this property.
public object
GetValue​(object obj)
obj The object whose property value will be returned.
Returns The property value of the specified object.
Returns the property value of a specified object.
public object
GetValue​(object obj, object[] index)
obj The object whose property value will be returned.
index Optional index values for indexed properties. The indexes of indexed properties are zero-based. This value should be <see langword="null" /> for non-indexed properties.
Returns The property value of the specified object.
Returns the property value of a specified object with optional index values for indexed properties.
public object
GetValue​(object obj, BindingFlags invokeAttr, Binder binder, object[] index, Globalization.CultureInfo culture)
obj The object whose property value will be returned.
invokeAttr A bitwise combination of the following enumeration members that specify the invocation attribute: <see langword="InvokeMethod" /> , <see langword="CreateInstance" /> , <see langword="Static" /> , <see langword="GetField" /> , <see langword="SetField" /> , <see langword="GetProperty" /> , and <see langword="SetProperty" /> . You must specify a suitable invocation attribute. For example, to invoke a static member, set the <see langword="Static" /> flag.
binder An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo" /> objects through reflection. If <paramref name="binder" /> is <see langword="null" /> , the default binder is used.
index Optional index values for indexed properties. This value should be <see langword="null" /> for non-indexed properties.
culture The culture for which the resource is to be localized. If the resource is not localized for this culture, the <see cref="P:System.Globalization.CultureInfo.Parent" /> property will be called successively in search of a match. If this value is <see langword="null" /> , the culture-specific information is obtained from the <see cref="P:System.Globalization.CultureInfo.CurrentUICulture" /> property.
Returns The property value of the specified object.
When overridden in a derived class, returns the property value of a specified object that has the specified binding, index, and culture-specific information.
public void
SetValue​(object obj, object value)
obj The object whose property value will be set.
value The new property value.
Sets the property value of a specified object.
public void
SetValue​(object obj, object value, object[] index)
obj The object whose property value will be set.
value The new property value.
index Optional index values for indexed properties. This value should be <see langword="null" /> for non-indexed properties.
Sets the property value of a specified object with optional index values for index properties.
public void
SetValue​(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, Globalization.CultureInfo culture)
obj The object whose property value will be set.
value The new property value.
invokeAttr A bitwise combination of the following enumeration members that specify the invocation attribute: <see langword="InvokeMethod" /> , <see langword="CreateInstance" /> , <see langword="Static" /> , <see langword="GetField" /> , <see langword="SetField" /> , <see langword="GetProperty" /> , or <see langword="SetProperty" /> . You must specify a suitable invocation attribute. For example, to invoke a static member, set the <see langword="Static" /> flag.
binder An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo" /> objects through reflection. If <paramref name="binder" /> is <see langword="null" /> , the default binder is used.
index Optional index values for indexed properties. This value should be <see langword="null" /> for non-indexed properties.
culture The culture for which the resource is to be localized. If the resource is not localized for this culture, the <see cref="P:System.Globalization.CultureInfo.Parent" /> property will be called successively in search of a match. If this value is <see langword="null" /> , the culture-specific information is obtained from the <see cref="P:System.Globalization.CultureInfo.CurrentUICulture" /> property.
When overridden in a derived class, sets the property value for a specified object that has the specified binding, index, and culture-specific information.
public object[]
GetCustomAttributes​(bool inherit)
Inherited from MemberInfo
inherit <see langword="true" /> to search this member's inheritance chain to find the attributes; otherwise, <see langword="false" /> . This parameter is ignored for properties and events.
Returns An array that contains all the custom attributes applied to this member, or an array with zero elements if no attributes are defined.
When overridden in a derived class, returns an array of all custom attributes applied to this member.
public object[]
GetCustomAttributes​(Type attributeType, bool inherit)
Inherited from MemberInfo
attributeType The type of attribute to search for. Only attributes that are assignable to this type are returned.
inherit <see langword="true" /> to search this member's inheritance chain to find the attributes; otherwise, <see langword="false" /> . This parameter is ignored for properties and events.
Returns An array of custom attributes applied to this member, or an array with zero elements if no attributes assignable to <paramref name="attributeType" /> have been applied.
When overridden in a derived class, returns an array of custom attributes applied to this member and identified by <see cref="T:System.Type" /> .
GetCustomAttributesData​()
Inherited from MemberInfo
Returns A generic list of <see cref="T:System.Reflection.CustomAttributeData" /> objects representing data about the attributes that have been applied to the target member.
Returns a list of <see cref="T:System.Reflection.CustomAttributeData" /> objects representing data about the attributes that have been applied to the target member.
public bool
HasSameMetadataDefinitionAs​(MemberInfo other)
Inherited from MemberInfo
public bool
IsDefined​(Type attributeType, bool inherit)
Inherited from MemberInfo
attributeType The type of custom attribute to search for. The search includes derived types.
inherit <see langword="true" /> to search this member's inheritance chain to find the attributes; otherwise, <see langword="false" /> . This parameter is ignored for properties and events.
Returns <see langword="true" /> if one or more instances of <paramref name="attributeType" /> or any of its derived types is applied to this member; otherwise, <see langword="false" /> .
When overridden in a derived class, indicates whether one or more attributes of the specified type or of its derived types is applied to this member.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns A string that represents the current object.
Returns a string that represents the current object.