Introduction to Reflection API


The PropertyInfo class discovers the attributes of a property and provides access to property metadata.

The PropertyInfo class is very similar to the FieldInfo class and also contains the ability to set the value of the property on an instance. It also gives you the ability to individually receive the get and set accessors as MethodInfo classes through the GetAccessors method.

Type myClassType = typeof(MyClass);

//Get public properties
System.Reflection.PropertyInfo[] propertyInfos = myClassType.GetProperties();


System.Reflection.MethodInfo[] accessorMethodInfos = propertyInfo.GetAccessors();

Other properties and methods you can check on MSDN


Get all properties from class MyClass and output it`s name and accessors methods names

using System; using System.Collections.G...


Page 7 of 11