Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MethodInfo.MemberType Property

Gets a value indicating that this member is a method.

[Visual Basic]
Overrides Public ReadOnly Property MemberType As MemberTypes
[C#]
public override MemberTypes MemberType {get;}
[C++]
public: __property MemberTypes get_MemberType();
[JScript]
public override function get MemberType() : MemberTypes;

Property Value

A MemberTypes object indicating that this member is a method.

Remarks

This is used when this method is being tested as generic member.

To get the MemberType property, first get the class Type. From the Type, get the MethodInfo. From the MethodInfo, get the MemberType.

Example

The following example displays the type of the specified member.

[Visual Basic] 
Imports System
Imports System.Reflection

Class MyMethodInfo

    Public Shared Function Main() As Integer
        Console.WriteLine("Reflection.MethodInfo")

        ' Get the Type and MethodInfo.
        Dim MyType As Type = Type.GetType("System.Reflection.FieldInfo")
        Dim Mymethodinfo As MethodInfo = MyType.GetMethod("GetValue")
        Console.WriteLine(MyType.FullName + "." + Mymethodinfo.Name)

        ' Get and display the MemberType property.
        Dim Mymembertypes As MemberTypes = Mymethodinfo.MemberType

        If MemberTypes.Constructor = Mymembertypes Then
            Console.WriteLine("MemberType is of type All.")

        ElseIf MemberTypes.Custom = Mymembertypes Then
            Console.WriteLine("MemberType is of type Custom.")

        ElseIf MemberTypes.Event = Mymembertypes Then
            Console.WriteLine("MemberType is of type Event.")

        ElseIf MemberTypes.Field = Mymembertypes Then
            Console.WriteLine("MemberType is of type Field.")

        ElseIf MemberTypes.Method = Mymembertypes Then
            Console.WriteLine("MemberType is of type Method.")

        ElseIf MemberTypes.Property = Mymembertypes Then
            Console.WriteLine("MemberType is of type Property.")

        ElseIf MemberTypes.TypeInfo = Mymembertypes Then
            Console.WriteLine("MemberType is of type TypeInfo.")

        End If
        Return 0
    End Function
End Class

[C#] 
using System;
using System.Reflection;
 
class MyMethodInfo
{
    public static int Main()
    {
        Console.WriteLine("Reflection.MethodInfo");
  
        // Get the Type and MethodInfo.
        Type MyType = Type.GetType("System.Reflection.FieldInfo");
        MethodInfo Mymethodinfo = MyType.GetMethod("GetValue");
        Console.WriteLine(MyType.FullName + "." + Mymethodinfo.Name);
  
        // Get and display the MemberType property.
        MemberTypes Mymembertypes = Mymethodinfo.MemberType;
      
 
        if (MemberTypes.Constructor == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type All.");
        }
        else if (MemberTypes.Custom == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Custom.");
        }
        else if (MemberTypes.Event == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Event.");
        }
        else if (MemberTypes.Field == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Field.");
        }
        else if (MemberTypes.Method == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Method.");
        }
        else if (MemberTypes.Property == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Property.");
        }
        else if (MemberTypes.TypeInfo == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type TypeInfo.");
        }
 
        return 0;
    }
}

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;

int main()
{
    Console::WriteLine(S"Reflection.MethodInfo");

    // Get the Type and MethodInfo.
    Type* MyType = Type::GetType(S"System.Reflection.FieldInfo");
    MethodInfo* Mymethodinfo = MyType->GetMethod(S"GetValue");
    Console::WriteLine(S"{0}.{1}", MyType->FullName, Mymethodinfo->Name);

    // Get and display the MemberType property.
    MemberTypes Mymembertypes = Mymethodinfo->MemberType;


    if (MemberTypes::Constructor == Mymembertypes)
    {
        Console::WriteLine(S"MemberType is of type All.");
    }
    else if (MemberTypes::Custom == Mymembertypes)
    {
        Console::WriteLine(S"MemberType is of type Custom.");
    }
    else if (MemberTypes::Event == Mymembertypes)
    {
        Console::WriteLine(S"MemberType is of type Event.");
    }
    else if (MemberTypes::Field == Mymembertypes)
    {
        Console::WriteLine(S"MemberType is of type Field.");
    }
    else if (MemberTypes::Method == Mymembertypes)
    {
        Console::WriteLine(S"MemberType is of type Method.");
    }
    else if (MemberTypes::Property == Mymembertypes)
    {
        Console::WriteLine(S"MemberType is of type Property.");
    }
    else if (MemberTypes::TypeInfo == Mymembertypes)
    {
        Console::WriteLine(S"MemberType is of type TypeInfo.");
    }

    return 0;
}

[JScript] 
import System;
import System.Reflection;
 
 class MyMethodInfo
 {
   public static function Main() : void
   {
       Console.WriteLine("Reflection.MethodInfo");
  
       //Get the Type and MethodInfo.
       var MyType : Type = Type.GetType("System.Reflection.FieldInfo");
       var Mymethodinfo : MethodInfo = MyType.GetMethod("GetValue");
       Console.WriteLine(MyType.FullName + "." + Mymethodinfo.Name);
  
       //Get and display the MemberType property.
       var Mymembertypes : MemberTypes = Mymethodinfo.MemberType;
      
 
       if ( MemberTypes.Constructor == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type All" );
       }
       else if ( MemberTypes.Custom == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type Custom" );
       }
       else if ( MemberTypes.Event == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type Event" );
       }
       else if ( MemberTypes.Field == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type Field" );
       }
       else if ( MemberTypes.Method == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type Method" );
       }
       else if ( MemberTypes.Property == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type Property" );
       }
       else if ( MemberTypes.TypeInfo == Mymembertypes )
       {
          Console.WriteLine( "MemberType is of type TypeInfo" );
       }
 
    }
 }
 MyMethodInfo.Main();
 /*
 This code produces the following output:
 
 Reflection.MethodInfo
 System.Reflection.FieldInfo.GetValue
 MemberType is of type Method
 */

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

MethodInfo Class | MethodInfo Members | System.Reflection Namespace

Show:
© 2014 Microsoft