PropertyInfo.GetGetMethod Yöntem

Tanım

Bu özellik için erişimciyi get temsil eden bir MethodInfo döndürür.

Aşırı Yüklemeler

GetGetMethod(Boolean)

Türetilmiş bir sınıfta geçersiz kılındığında, bu özellik için genel veya genel get olmayan erişimciyi döndürür.

GetGetMethod()

Bu özellik için ortak get erişimciyi döndürür.

GetGetMethod(Boolean)

Kaynak:
PropertyInfo.cs
Kaynak:
PropertyInfo.cs
Kaynak:
PropertyInfo.cs

Türetilmiş bir sınıfta geçersiz kılındığında, bu özellik için genel veya genel get olmayan erişimciyi döndürür.

C#
public abstract System.Reflection.MethodInfo? GetGetMethod (bool nonPublic);
C#
public abstract System.Reflection.MethodInfo GetGetMethod (bool nonPublic);

Parametreler

nonPublic
Boolean

Genel get olmayan bir erişimcinin döndürülmesi gerekip gerekmediğini gösterir. true ortak olmayan bir erişimci döndürülecekse; aksi takdirde , false.

Döndürülenler

MethodInfo isenonPublic, bu özelliğin erişimcisini get temsil eden bir nesne.true varsa falsenonPublic ve get erişimci ortak değilse veya nonPublictrue varsa ancak hiç erişimci yoksa get döndürürnull.

Uygulamalar

Özel durumlar

İstenen yöntem genel değil ve çağıranın bu genel olmayan yöntemi yansıtması gerekmez ReflectionPermission .

Örnekler

Aşağıdaki örnek, belirtilen özellik için genel veya genel get olmayan erişimciyi görüntüler.

C#
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;
    }
}

Açıklamalar

Bu özellik get erişimcisini temsil eden özelliktir MethodInfo .

yöntemini kullanmak GetGetMethod için önce sınıfını Typealın. içinden Typeöğesini alın PropertyInfo. içinden PropertyInfoyöntemini kullanın GetGetMethod .

Şunlara uygulanır

.NET 9 ve diğer sürümler
Ürün Sürümler
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.5, 1.6, 2.0, 2.1

GetGetMethod()

Kaynak:
PropertyInfo.cs
Kaynak:
PropertyInfo.cs
Kaynak:
PropertyInfo.cs

Bu özellik için ortak get erişimciyi döndürür.

C#
public System.Reflection.MethodInfo? GetGetMethod ();
C#
public System.Reflection.MethodInfo GetGetMethod ();

Döndürülenler

MethodInfo Bu özellik için ortak get erişimciyi temsil eden veya null erişimci genel olmayan veya mevcut olmayan get bir nesne.

Uygulamalar

Açıklamalar

Bu, parametresi olarak ayarlanmış soyut GetGetMethod yöntem için bir uygulama sağlayan bir kolaylık yöntemidir nonPublicfalse.

yöntemini kullanmak GetGetMethod için önce sınıfını Typealın. içinden Typeöğesini alın PropertyInfo. içinden PropertyInfoyöntemini kullanın GetGetMethod .

Şunlara uygulanır

.NET 9 ve diğer sürümler
Ürün Sürümler
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.5, 1.6, 2.0, 2.1