MethodInfo.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 method.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.Reflection.MemberTypesA MemberTypes value indicating that this member is a method.
This property overrides MemberInfo.MemberType. Therefore, when you examine a set of MemberInfo objects — for example, the array returned by GetMembers — the MemberType property returns MemberTypes.Method only when a given member is a method.
To get the MemberType property, first get the class Type. From the Type, get the MethodInfo. From the MethodInfo, get the MemberType.
The following example displays the type of the specified member.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |
Imports System.Reflection Class Example Public Shared Function Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) As Integer outputBlock.Text &= "Reflection.MethodInfo" & vbCrLf ' Get the Type and MethodInfo. Dim MyType As Type = Type.GetType("System.Reflection.FieldInfo") Dim Mymethodinfo As MethodInfo = MyType.GetMethod("GetValue") outputBlock.Text &= MyType.FullName + "." + Mymethodinfo.Name & vbCrLf ' Get and display the MemberType property. Dim Mymembertypes As MemberTypes = Mymethodinfo.MemberType If MemberTypes.Constructor = Mymembertypes Then outputBlock.Text &= "MemberType is of type All." & vbCrLf ElseIf MemberTypes.Custom = Mymembertypes Then outputBlock.Text &= "MemberType is of type Custom." & vbCrLf ElseIf MemberTypes.Event = Mymembertypes Then outputBlock.Text &= "MemberType is of type Event." & vbCrLf ElseIf MemberTypes.Field = Mymembertypes Then outputBlock.Text &= "MemberType is of type Field." & vbCrLf ElseIf MemberTypes.Method = Mymembertypes Then outputBlock.Text &= "MemberType is of type Method." & vbCrLf ElseIf MemberTypes.Property = Mymembertypes Then outputBlock.Text &= "MemberType is of type Property." & vbCrLf ElseIf MemberTypes.TypeInfo = Mymembertypes Then outputBlock.Text &= "MemberType is of type TypeInfo." & vbCrLf End If Return 0 End Function End Class
Note: