Retrieves the Type of property reflected by this PropertyInfo object.
[Visual Basic] Overridable Public ReadOnly Property MemberType As MemberTypes [C#] public MemberTypes MemberType {override get;} [C++] public: __property virtual MemberTypes get_MemberType(); [JScript] public function get MemberType() : MemberTypes;
Read-only.
MemberType is a subclass of MemberInfo and specifies the type of member this is. Member types are constructors, properties, fields, methods, etc. Since this is a PropertyInfo property, the returned type is a Property.
To get the MemberType property, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, get the MemberType value.
[C#]
class Mypropertyinfo { public static int Main() { Console.WriteLine("\nReflection.PropertyInfo"); //Get the type and PropertyInfo Type MyType = Type.GetType("System.Reflection.MemberInfo"); PropertyInfo Mypropertyinfo = MyType.GetProperty("Name"); //Read and display the MemberType property Console.Write("\nMemberType = " + EnumInfo.ToString(Type.GetType("System.Reflection.MemberTypes"), Mypropertyinfo.MemberType)); return 0; } } Produces the following output Reflection.PropertyInfo MemberType = Property
PropertyInfo Class | PropertyInfo Members | System.Reflection Namespace