System.Reflection.PropertyInfo.GetSetMethod Method

When overridden in a derived class, returns the set accessor for this property.

Syntax

public abstract MethodInfo GetSetMethod (bool nonPublic)

Parameters

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

Returns

A System.Reflection.MethodInfo object representing the Set method for this property.

The set accessor is public.

-or-

nonPublic is true and the set accessor is non-public.

null

nonPublic is true, but the property is read-only.

-or-

nonPublic is false and the set accessor is non-public.

-or-

There is no set accessor.

Exceptions

TypeReason
MethodAccessException nonPublic is true, the Set 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

To use the GetSetMethod method, first get the class Type. From the Type, get the System.Reflection.PropertyInfo. From the PropertyInfo, use the GetSetMethod 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