MethodInfo.MemberType 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 멤버가 메서드임을 나타내는 MemberTypes 값을 가져옵니다.
public:
virtual property System::Reflection::MemberTypes MemberType { System::Reflection::MemberTypes get(); };
public override System.Reflection.MemberTypes MemberType { get; }
member this.MemberType : System.Reflection.MemberTypes
Public Overrides ReadOnly Property MemberType As MemberTypes
속성 값
이 멤버가 메서드임을 나타내는 MemberTypes 값입니다.
구현
예제
다음 예제에서는 지정된 멤버의 형식을 표시합니다.
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;
}
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;
}
}
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
설명
이 속성은 를 재정의합니다 MemberInfo.MemberType. 따라서 개체 집합 MemberInfo (예: 에서 반환된 GetMembers 배열)을 검사할 때 속성은 MemberType 지정된 멤버가 메서드인 경우에만 를 반환합니다 MemberTypes.Method .
속성을 얻으려면 MemberType
먼저 클래스 Type
를 가져옵니다. 에서 를 Type
가져옵니다 MethodInfo
. 에서 를 MethodInfo
가져옵니다 MemberType
.
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET