MemberInfo.ReflectedType 속성

정의

MemberInfo의 이 인스턴스를 가져오는 데 사용된 클래스 개체를 가져옵니다.Gets the class object that was used to obtain this instance of MemberInfo.

public:
 abstract property Type ^ ReflectedType { Type ^ get(); };
public abstract Type? ReflectedType { get; }
public abstract Type ReflectedType { get; }
member this.ReflectedType : Type
Public MustOverride ReadOnly Property ReflectedType As Type

속성 값

Type

Type 개체를 얻는 데 사용된 MemberInfo 개체입니다.The Type object through which this MemberInfo object was obtained.

구현

예제

다음 코드 예제에서는를 통해 ReflectedType 가져온에서 멤버를 볼 때를 변경 하는 방법과를 Object.ToString MemberInfo Object MemberInfo MemberInfo 상속 하지만를 재정의 하지 않는 클래스 자체에서 가져온 Object Object.ToString 에서 변경 하는 방법을 보여 줍니다.The following code example shows how the ReflectedType changes when the member Object.ToString is viewed from a MemberInfo obtained from type Object and from a MemberInfo obtained from the MemberInfo class itself, which inherits Object but does not override Object.ToString.

using namespace System;
using namespace System::Reflection;

int main()
{
    MemberInfo^ m1 = Object::typeid->GetMethod("ToString");
    MemberInfo^ m2 = MemberInfo::typeid->GetMethod("ToString");

    Console::WriteLine("m1.DeclaringType: {0}", m1->DeclaringType);
    Console::WriteLine("m1.ReflectedType: {0}", m1->ReflectedType);
    Console::WriteLine();
    Console::WriteLine("m2.DeclaringType: {0}", m2->DeclaringType);
    Console::WriteLine("m2.ReflectedType: {0}", m2->ReflectedType);

    //Console::ReadLine();
}

/* This code example produces the following output:

m1.DeclaringType: System.Object
m1.ReflectedType: System.Object

m2.DeclaringType: System.Object
m2.ReflectedType: System.Reflection.MemberInfo
 */
using System;
using System.Reflection;

public class Example
{
    static void Main()
    {
        MemberInfo m1 = typeof(Object).GetMethod("ToString");
        MemberInfo m2 = typeof(MemberInfo).GetMethod("ToString");

        Console.WriteLine("m1.DeclaringType: {0}", m1.DeclaringType);
        Console.WriteLine("m1.ReflectedType: {0}", m1.ReflectedType);
        Console.WriteLine();
        Console.WriteLine("m2.DeclaringType: {0}", m2.DeclaringType);
        Console.WriteLine("m2.ReflectedType: {0}", m2.ReflectedType);

        //Console.ReadLine();
    }
}

/* This code example produces the following output:

m1.DeclaringType: System.Object
m1.ReflectedType: System.Object

m2.DeclaringType: System.Object
m2.ReflectedType: System.Reflection.MemberInfo
 */
Imports System.Reflection

Module Example

    Sub Main()

        Dim m1 As MemberInfo = GetType(Object).GetMethod("ToString")
        Dim m2 As MemberInfo = GetType(MemberInfo).GetMethod("ToString")

        Console.WriteLine("m1.DeclaringType: {0}", m1.DeclaringType)
        Console.WriteLine("m1.ReflectedType: {0}", m1.ReflectedType)
        Console.WriteLine()
        Console.WriteLine("m2.DeclaringType: {0}", m2.DeclaringType)
        Console.WriteLine("m2.ReflectedType: {0}", m2.ReflectedType)

        'Console.ReadLine()
    End Sub
End Module

' This code example produces the following output:
'
' m1.DeclaringType: System.Object
' m1.ReflectedType: System.Object
'
' m2.DeclaringType: System.Object
' m2.ReflectedType: System.Reflection.MemberInfo
'

설명

ReflectedType속성은 Type 이 인스턴스를 가져오는 데 사용 된 개체를 검색 합니다 MemberInfo .The ReflectedType property retrieves the Type object that was used to obtain this instance of MemberInfo. DeclaringType MemberInfo 개체가 기본 클래스에서 상속 된 멤버를 나타내는 경우 속성의 값과 다를 수 있습니다.This may differ from the value of the DeclaringType property if this MemberInfo object represents a member that is inherited from a base class.

MemberInfo개체가 전역 멤버인 경우 (즉, Module.GetMethods 모듈에서 전역 메서드를 반환 하는 메서드에서 가져온 경우) 반환 되는는 DeclaringType null 입니다.If the MemberInfo object is a global member (that is, if it was obtained from the Module.GetMethods method, which returns global methods on a module), the returned DeclaringType will be null.

적용 대상