Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MethodInfo::MemberType Property

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

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

public:
virtual property MemberTypes MemberType {
	MemberTypes get () override;
}

Property Value

Type: System.Reflection::MemberTypes
A MemberTypes value indicating that this member is a method.

Implements

_MethodInfo::MemberType
_MemberInfo::MemberType

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.

using namespace System;
using namespace System::Reflection;
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( "{0}.{1}", 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;
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft