Retrieves the type of the field of this property.
[Visual Basic] MustOverride Public ReadOnly Property PropertyType As Type [C#] public Type PropertyType {abstract get;} [C++] public: __property virtual Type* get_PropertyType() = 0; [JScript] public abstract function get PropertyType() : Type;
Read-only. The Type of this property.
The Type is string, Boolean, Integer, etc.
To get the PropertyType property, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, get the PropertyType value.
[C#]
class Mypropertyinfo { public static int Main() { Console.WriteLine("\nReflection.PropertyInfo"); //Get the type and PropertyInfo Type MyTypea = Type.GetType("System.Reflection.MemberInfo"); PropertyInfo Mypropertyinfoa = MyTypea.GetProperty("Name"); Type MyTypeb = Type.GetType("System.Reflection.MethodBase"); PropertyInfo Mypropertyinfob = MyTypeb.GetProperty("IsFinal"); //Read and display the PropertyType property Console.Write ("\n" + MyTypea.FullName + "." + Mypropertyinfoa.Name + " has a PropertyType of " + Mypropertyinfoa.PropertyType); Console.Write("\n" + MyTypeb.FullName + "." + Mypropertyinfob.Name + " has a PropertyType of " + Mypropertyinfob.PropertyType); return 0; } } Produces the following output Reflection.PropertyInfo System.Reflection.MemberInfo.Name has a PropertyType of System.String System.Reflection.MethodBase.IsFinal has a PropertyType of Boolean
PropertyInfo Class | PropertyInfo Members | System.Reflection Namespace