다음을 통해 공유


MemberInfo.MemberType 속성

파생 클래스에서 재정의되는 경우 메서드, 생성자, 이벤트 등의 멤버 형식을 나타내는 MemberTypes 값을 가져옵니다.

네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public MustOverride ReadOnly Property MemberType As MemberTypes
‘사용 방법
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

속성 값

멤버 형식을 나타내는 MemberTypes 값입니다.

설명

이 속성은 파생 클래스에서 재정의되고, 재정의는 해당 멤버 형식을 반환합니다. 따라서 GetMembers에서 반환하는 배열 등의 MemberInfo 개체 집합을 조사할 때 MemberType 속성을 사용하여 지정된 멤버의 멤버 형식을 확인할 수 있습니다.

MemberType 속성을 가져오려면 Type 클래스를 가져옵니다. Type에서 MethodInfo 배열을 가져옵니다. MethodInfo 배열에서 MemberTypes를 가져옵니다.

예제

다음 예제에서는 지정된 클래스의 멤버 이름과 형식을 표시합니다.

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();

플랫폼

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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

MemberInfo 클래스
MemberInfo 멤버
System.Reflection 네임스페이스
MemberTypes