System.Reflection.PropertyInfo.GetGetMethod Method

When overridden in a derived class, returns the public or non-public get accessor for this property.

Syntax

public abstract MethodInfo GetGetMethod (bool nonPublic)

Parameters

nonPublic
Indicates whether a non-public get accessor should be returned. true if a non-public accessor is to be returned; otherwise, false.

Returns

A MethodInfo object representing the get accessor for this property, if nonPublic is true. Returns null if nonPublic is false and the get accessor is non-public, or if nonPublic is true but no get accessors exist.

Exceptions

TypeReason
MethodAccessException nonPublic is true, the Get accessor for the property reflected by the current instance is non-public, and the caller does not have System.Security.Permissions.ReflectionPermission to reflect on non-public methods.

Remarks

This property is the System.Reflection.MethodInfo representing the get accessor.

To use the GetGetMethod method, first get the class Type. From the Type, get the System.Reflection.PropertyInfo. From the System.Reflection.PropertyInfo, use the GetGetMethod method.

Permissions

TypeReason
System.Security.Permissions.ReflectionPermissionRequires permission to reflect non-public members of a type in loaded assemblies. See System.Security.Permissions.ReflectionPermissionFlag.TypeInformation.

Requirements

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0