Export (0) Print
Expand All

PropertyInfo Class

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

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

public abstract class PropertyInfo extends MemberInfo implements _PropertyInfo

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.

NoteNote:

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.

Calling ICustomAttributeProvider.GetCustomAttributes on PropertyInfo when the inherit parameter of GetCustomAttributes is true does not walk the type hierarchy. Use System.Attribute to inherit custom attributes.

Notes to Inheritors:

When you inherit from PropertyInfo, you must override the following members: GetValue, SetValue, GetAccessors, GetGetMethod, GetSetMethod, and GetIndexParameters.

This example shows how to use various reflection classes to analyze the metadata contained in an assembly.

NoteNote:

This example generates about 55,000 lines of data, which you can redirect to a text file at the command prompt, as follows: example.exe > propertyinfo.txt

No code example is currently available or this language may not be supported.

This type is thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft