PropertyInfo.GetGetMethod 메서드

정의

이 속성에 대한 MethodInfo 접근자를 나타내는 get를 반환합니다.

오버로드

GetGetMethod(Boolean)

파생 클래스에서 재정의되는 경우 이 속성에 대한 공용 또는 공용이 아닌 get 접근자를 반환합니다.

GetGetMethod()

이 속성의 public get 접근자를 반환합니다.

GetGetMethod(Boolean)

Source:
PropertyInfo.cs
Source:
PropertyInfo.cs
Source:
PropertyInfo.cs

파생 클래스에서 재정의되는 경우 이 속성에 대한 공용 또는 공용이 아닌 get 접근자를 반환합니다.

public:
 abstract System::Reflection::MethodInfo ^ GetGetMethod(bool nonPublic);
public abstract System.Reflection.MethodInfo? GetGetMethod (bool nonPublic);
public abstract System.Reflection.MethodInfo GetGetMethod (bool nonPublic);
abstract member GetGetMethod : bool -> System.Reflection.MethodInfo
Public MustOverride Function GetGetMethod (nonPublic As Boolean) As MethodInfo

매개 변수

nonPublic
Boolean

public이 아닌 get 접근자를 반환할지 여부를 나타냅니다. public이 아닌 접근자를 반환해야 할 경우 true이고, 그러지 않은 경우 false입니다.

반환

MethodInfoget인 경우 nonPublic 접근자를 나타내는 true 개체입니다. nullnonPublic이고 false 접근자가 public이 아닌 경우 또는 getnonPublic이고 true 접근자가 없는 경우 get을 반환합니다.

구현

예외

요청된 메서드가 public이 아니고 호출자에 이 public이 아닌 메서드에 반영할 ReflectionPermission이 없습니다.

예제

다음 예제에서는 지정된 속성에 대한 public 또는 non-public get 접근자를 표시합니다.

using namespace System;
using namespace System::Reflection;

// Define a property.
public ref class Myproperty
{
private:
   String^ caption;

public:
   Myproperty()
      : caption( "A Default caption" )
   {}


   property String^ Caption 
   {
      String^ get()
      {
         return caption;
      }

      void set( String^ value )
      {
         if ( caption != value )
         {
            caption = value;
         }
      }

   }

};

int main()
{
   Console::WriteLine( "\nReflection.PropertyInfo" );
   
   // Get the type and PropertyInfo for two separate properties.
   Type^ MyTypea = Type::GetType( "Myproperty" );
   PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" );
   Type^ MyTypeb = Type::GetType( "System.Reflection.MethodInfo" );
   PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "MemberType" );
   
   // Get and display the GetGetMethod method for each property.
   MethodInfo^ Mygetmethodinfoa = Mypropertyinfoa->GetGetMethod();
   Console::Write( "\nGetAccessor for {0} returns a {1}", Mypropertyinfoa->Name, Mygetmethodinfoa->ReturnType );
   MethodInfo^ Mygetmethodinfob = Mypropertyinfob->GetGetMethod();
   Console::Write( "\nGetAccessor for {0} returns a {1}", Mypropertyinfob->Name, Mygetmethodinfob->ReturnType );
   
   // Display the GetGetMethod without using the MethodInfo.
   Console::Write( "\n{0}.{1} GetGetMethod - {2}", MyTypea->FullName, Mypropertyinfoa->Name, Mypropertyinfoa->GetGetMethod() );
   Console::Write( "\n{0}.{1} GetGetMethod - {2}", MyTypeb->FullName, Mypropertyinfob->Name, Mypropertyinfob->GetGetMethod() );
   return 0;
}
using System;
using System.Reflection;

// Define a property.
public class Myproperty
{
    private string caption = "A Default caption";
    public string Caption
    {
        get{return caption;}
        set {if(caption!=value) {caption = value;}
        }
    }
}

class Mypropertyinfo
{
    public static int Main()
    {
        Console.WriteLine ("\nReflection.PropertyInfo");

        // Get the type and PropertyInfo for two separate properties.
        Type MyTypea = Type.GetType("Myproperty");
        PropertyInfo Mypropertyinfoa = MyTypea.GetProperty("Caption");
        Type MyTypeb = Type.GetType("System.Reflection.MethodInfo");
        PropertyInfo Mypropertyinfob = MyTypeb.GetProperty("MemberType");

        // Get and display the GetGetMethod method for each property.
        MethodInfo Mygetmethodinfoa = Mypropertyinfoa.GetGetMethod();
        Console.Write ("\nGetAccessor for " + Mypropertyinfoa.Name
            + " returns a " + Mygetmethodinfoa.ReturnType);
        MethodInfo Mygetmethodinfob = Mypropertyinfob.GetGetMethod();
        Console.Write ("\nGetAccessor for " + Mypropertyinfob.Name
            + " returns a " + Mygetmethodinfob.ReturnType);

        // Display the GetGetMethod without using the MethodInfo.
        Console.Write ("\n" + MyTypea.FullName + "." + Mypropertyinfoa.Name
            + " GetGetMethod - " + Mypropertyinfoa.GetGetMethod());
        Console.Write ("\n" + MyTypeb.FullName + "." + Mypropertyinfob.Name
            + " GetGetMethod - " + Mypropertyinfob.GetGetMethod());
        return 0;
    }
}
Imports System.Reflection

' Define a property.
Public Class Myproperty
    Private myCaption As String = "A Default caption"

    Public Property Caption() As String
        Get
            Return myCaption
        End Get
        Set(ByVal Value As String)
            If myCaption <> value Then
                myCaption = value
            End If
        End Set
    End Property
End Class

Class Mypropertyinfo

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.CrLf & "Reflection.PropertyInfo")

        ' Get the type and PropertyInfo for two separate properties.
        Dim MyTypea As Type = Type.GetType("Myproperty")
        Dim Mypropertyinfoa As PropertyInfo = MyTypea.GetProperty("Caption")
        Dim MyTypeb As Type = Type.GetType("System.Reflection.MethodInfo")
        Dim Mypropertyinfob As PropertyInfo = MyTypeb.GetProperty("MemberType")

        ' Get and display the GetGetMethod Method for each property.
        Dim Mygetmethodinfoa As MethodInfo = Mypropertyinfoa.GetGetMethod()
        Console.WriteLine("GetAccessor for " & _
           Mypropertyinfoa.Name & " returns a " & _
           Mygetmethodinfoa.ReturnType.ToString())
        Dim Mygetmethodinfob As MethodInfo = Mypropertyinfob.GetGetMethod()
        Console.WriteLine("GetAccessor for " & _
           Mypropertyinfob.Name & " returns a " & _
           Mygetmethodinfob.ReturnType.ToString())

        ' Display the GetGetMethod without using the MethodInfo.
        Console.WriteLine(MyTypea.FullName & "." & _
           Mypropertyinfoa.Name & " GetGetMethod - " & _
           Mypropertyinfoa.GetGetMethod().ToString())
        Console.WriteLine(MyTypeb.FullName & "." & _
           Mypropertyinfob.Name & " GetGetMethod - " & _
           Mypropertyinfob.GetGetMethod().ToString())
        Return 0
    End Function
End Class

설명

이 속성은 MethodInfo get 접근자를 나타내는 입니다.

메서드를 GetGetMethod 사용하려면 먼저 클래스 Type를 가져옵니다. 에서 를 Type가져옵니다 PropertyInfo. 에서 PropertyInfo메서드를 GetGetMethod 사용합니다.

적용 대상

GetGetMethod()

Source:
PropertyInfo.cs
Source:
PropertyInfo.cs
Source:
PropertyInfo.cs

이 속성의 public get 접근자를 반환합니다.

public:
 System::Reflection::MethodInfo ^ GetGetMethod();
public:
 virtual System::Reflection::MethodInfo ^ GetGetMethod();
public System.Reflection.MethodInfo? GetGetMethod ();
public System.Reflection.MethodInfo GetGetMethod ();
member this.GetGetMethod : unit -> System.Reflection.MethodInfo
abstract member GetGetMethod : unit -> System.Reflection.MethodInfo
override this.GetGetMethod : unit -> System.Reflection.MethodInfo
Public Function GetGetMethod () As MethodInfo

반환

이 속성에 대한 public MethodInfo 접근자를 나타내는 get 개체입니다. null 접근자가 public이 아니거나 없으면 get입니다.

구현

설명

매개 변수가 로 설정된 false추상 GetGetMethod 메서드에 대한 구현을 nonPublic 제공하는 편리한 메서드입니다.

메서드를 GetGetMethod 사용하려면 먼저 클래스 Type를 가져옵니다. 에서 를 Type가져옵니다 PropertyInfo. 에서 PropertyInfo메서드를 GetGetMethod 사용합니다.

적용 대상