PropertyInfo.MemberType Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets a MemberTypes value indicating that this member is a property.
Assembly: mscorlib (in mscorlib.dll)
This property overrides MemberType. Therefore, when you examine a set of MemberInfo objects — for example, the array returned by GetMembers — the MemberType property returns MemberTypes.Property only when a given member is a property.
MemberType is a derived class of MemberInfo and specifies the type of member this is. Member types are constructors, properties, fields, and methods. Because 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.
The following example displays the MemberType of a property.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |
using System; using System.Reflection; class Example { public static int Demo(System.Windows.Controls.TextBlock outputBlock) { outputBlock.Text += "\nReflection.PropertyInfo" + "\n"; // Get the type and PropertyInfo. Type MyType = Type.GetType("System.Reflection.MemberInfo"); PropertyInfo Example = MyType.GetProperty("Name"); // Read and display the MemberType property. outputBlock.Text += "\nMemberType = " + Example.MemberType.ToString(); return 0; } }
Note: