Share via


PropertyInfo Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

Inheritance Hierarchy

System. . :: . .Object
  System.Reflection. . :: . .MemberInfo
    System.Reflection..::..PropertyInfo

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

Syntax

'Declaration
<SerializableAttribute> _
Public MustInherit Class PropertyInfo _
    Inherits MemberInfo
[SerializableAttribute]
public abstract class PropertyInfo : MemberInfo
[SerializableAttribute]
public ref class PropertyInfo abstract : public MemberInfo
[<AbstractClass>]
[<SerializableAttribute>]
type PropertyInfo =  
    class
        inherit MemberInfo
    end
public abstract class PropertyInfo extends MemberInfo

The PropertyInfo type exposes the following members.

Constructors

  Name Description
Protected method PropertyInfo Initializes a new instance of the PropertyInfo class.

Top

Properties

  Name Description
Public property DeclaringType Gets the class that declares this member. (Inherited from MemberInfo.)
Public property MemberType When overridden in a derived class, gets a MemberTypes value indicating the type of the member — method, constructor, event, and so on. (Inherited from MemberInfo.)
Public property Name Gets the name of the current member. (Inherited from MemberInfo.)
Public property PropertyType Gets the type of this property.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method GetValue Returns the property value of a specified object with optional index values for indexed properties.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method SetValue Sets the property value of a specified object with optional index values for index properties.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

Properties are logically the same as fields. A property is a named aspect of an object's state whose value is typically accessible through get and set accessors. Properties may be read-only, in which case a set routine is not supported.

Note

To determine whether a property is static, you must obtain the MethodInfo for the get or set accessor, by calling the GetGetMethod or the GetSetMethod method, and examine its IsStatic property.

Several methods in this class assume that the get accessor and set accessor methods of a property have certain formats. The signatures of the get and set methods must match the following convention:

  • The return type of the get method and the last argument of the set method must be identical. This is the type of the property.

  • The get and set methods must have the same number, type, and order of indices.

If this format is not followed, the behavior of the GetValue and SetValue methods is undefined.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Reflection Namespace