Freigeben über


MemberInfo.MemberType-Eigenschaft

Ruft beim Überschreiben in einer abgeleiteten Klasse einen MemberTypes-Wert ab, der den Typ des Members angibt, z. B. Methode, Konstruktor, Ereignis usw.

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

Syntax

'Declaration
Public MustOverride ReadOnly Property MemberType As MemberTypes
'Usage
Dim instance As MemberInfo
Dim value As MemberTypes

value = instance.MemberType
public abstract MemberTypes MemberType { get; }
public:
virtual property MemberTypes MemberType {
    MemberTypes get () abstract;
}
/** @property */
public abstract MemberTypes get_MemberType ()
public abstract function get MemberType () : MemberTypes

Eigenschaftenwert

Ein MemberTypes-Wert, der den Membertyp angibt.

Hinweise

Diese Eigenschaft wird in abgeleiteten Klassen überschrieben, und die Überschreibung gibt den entsprechenden Membertyp zurück. Deshalb kann die MemberType-Eigenschaft zum Bestimmen eines Membertyps eines beliebigen Members verwendet werden, wenn Sie MemberInfo-Objekte überprüfen, beispielsweise das von der GetMembers-Methode zurückgegebene Array.

Um die MemberType-Eigenschaft abzurufen, rufen Sie die Type-Klasse ab. Rufen Sie aus Type das MethodInfo-Array ab. Rufen Sie MemberTypes aus dem MethodInfo-Array ab.

Beispiel

Im folgenden Beispiel werden der Membername und -typ einer angegebenen Klasse angezeigt.

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Class Mymemberinfo

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.Cr + "Reflection.MemberInfo")

        ' Get the Type and MemberInfo.
        Dim MyType As Type = Type.GetType("System.Reflection.PropertyInfo")
        Dim Mymemberinfoarray As MemberInfo() = MyType.GetMembers()

        ' Get the MemberType method and display the elements.
        Console.Write(ControlChars.Cr + "There are {0} members in ", _
           Mymemberinfoarray.GetLength(0))
        Console.Write("{0}.", MyType.FullName)

        Dim counter As Integer
        For counter = 0 To Mymemberinfoarray.Length - 1
            Console.Write(ControlChars.CrLf + counter.ToString() + ". " _
               + Mymemberinfoarray(counter).Name _
               + " Member type - " _
               + Mymemberinfoarray(counter).MemberType.ToString())
        Next counter
        Return 0
    End Function
End Class
using System;
using System.Reflection;
 
class Mymemberinfo
{
    public static int Main()
    {
        Console.WriteLine ("\nReflection.MemberInfo");
       
        // Get the Type and MemberInfo.
        Type MyType = Type.GetType("System.Reflection.PropertyInfo");
        MemberInfo[] Mymemberinfoarray = MyType.GetMembers();
  
        // Get the MemberType method and display the elements.
        Console.Write("\nThere are {0} members in ", Mymemberinfoarray.GetLength(0));
        Console.Write("{0}.", MyType.FullName);
  
        for (int counter = 0; counter < Mymemberinfoarray.Length; counter++)
        {
            Console.Write("\n" + counter + ". " 
                + Mymemberinfoarray[counter].Name
                + " Member type - " +
                Mymemberinfoarray[counter].MemberType.ToString());
        }
        return 0;
    }
}
using namespace System;
using namespace System::Reflection;
int main()
{
   Console::WriteLine( "\nReflection.MemberInfo" );
   
   // Get the Type and MemberInfo.
   Type^ MyType = Type::GetType( "System.Reflection.PropertyInfo" );
   array<MemberInfo^>^Mymemberinfoarray = MyType->GetMembers();
   
   // Get the MemberType method and display the elements.
   Console::Write( "\nThere are {0} members in ", Mymemberinfoarray->GetLength( 0 ) );
   Console::Write( "{0}.", MyType->FullName );
   for ( int counter = 0; counter < Mymemberinfoarray->Length; counter++ )
   {
      Console::Write( "\n{0}. {1} Member type - {2}", counter, Mymemberinfoarray[ counter ]->Name, Mymemberinfoarray[ counter ]->MemberType );

   }
   return 0;
}
import System.*;
import System.Reflection.*;

class MyMemberInfo
{
    public static void main(String[] args)
    {
        Console.WriteLine("\nReflection.MemberInfo");

        // Get the Type and MemberInfo.
        Type myType = Type.GetType("System.Reflection.PropertyInfo");
        MemberInfo myMemberInfoArray[] = myType.GetMembers();

        // Get the MemberType method and display the elements.
        Console.Write("\nThere are {0} members in ",
            String.valueOf(myMemberInfoArray.GetLength(0)));
        Console.Write("{0}.", myType.get_FullName());

        for (int counter=0; counter < myMemberInfoArray.length; counter++) {
            Console.Write(("\n" + counter + ". " 
                + myMemberInfoArray[counter].get_Name() + " Member type - "
                + myMemberInfoArray[counter].get_MemberType().toString()));
        } 
    } //main
} //MyMemberInfo
import System;
import System.Reflection;
 
 class Mymemberinfo
 {
    public static function Main() : void
    {
       Console.WriteLine ("\nReflection.MemberInfo");
       
       //Get the Type and MemberInfo.
       var MyType : Type = Type.GetType("System.Reflection.PropertyInfo");
       var Mymemberinfoarray : MemberInfo[] = MyType.GetMembers();
  
       //Get the MemberType method and display the elements.
       Console.Write("\nThere are {0} members in ",
          Mymemberinfoarray.GetLength(0));
       Console.Write("{0}.", MyType.FullName);
  
       for (var counter : int in Mymemberinfoarray)
       {
          Console.Write("\n" + counter + ". " 
             + Mymemberinfoarray[counter].Name
             + " Member type - " +
             Mymemberinfoarray[counter].MemberType.ToString());
       }
    }
 }
 Mymemberinfo.Main();

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

MemberInfo-Klasse
MemberInfo-Member
System.Reflection-Namespace
MemberTypes