MemberInfo.MemberType Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

When overridden in a derived class, gets a MemberTypes value indicating the type of the member — method, constructor, event, and so on.

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

Syntax

Public MustOverride ReadOnly Property MemberType As MemberTypes
public abstract MemberTypes MemberType { get; }

Property Value

Type: System.Reflection..::.MemberTypes
The type of member.

Remarks

This property is overridden in derived classes, and the override returns the appropriate member type. Therefore, when you examine a set of MemberInfo objects — for example, the array returned by GetMembers — the MemberType property can be used to determine the member type of any given member.

To get the MemberType property, get the class Type. From the Type, get the MethodInfo array. From the MethodInfo array, get the MemberTypes.

Examples

The following example displays the member name and type of a specified class.

Imports System.Reflection

Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) 

      ' Get the Type and MemberInfo.
      Dim MyType As Type = GetType(System.Threading.Thread)

      ' Display the MemberType and the member.
      outputBlock.Text &= String.Format("There are {0} members in {1}:" & vbLf, _
         MyType.GetMembers().Length, MyType.FullName)

      For Each mi As MemberInfo In MyType.GetMembers()
         outputBlock.Text &= String.Format("  {0} - {1}" & vbLf, _
            mi.MemberType, mi)
      Next 

   End Sub
End Class
using System;
using System.Reflection;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // Get the Type and MemberInfo.
      Type MyType = typeof(System.Threading.Thread);

      // Display the MemberType and the member.
      outputBlock.Text += String.Format("There are {0} members in {1}:\n", 
         MyType.GetMembers().Length, MyType.FullName);

      foreach (MemberInfo mi in MyType.GetMembers())
      {
         outputBlock.Text += String.Format("  {0} - {1}\n",
            mi.MemberType, mi);
      }
   }
}

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

MemberInfo Class

System.Reflection Namespace

MemberTypes