Windows Dev Center

MethodInfo.MemberType Property

Gets a MemberTypes value indicating that this member is a method.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Overrides ReadOnly Property MemberType As MemberTypes

Property Value

Type: System.Reflection.MemberTypes
A 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.


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


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft