Open sandboxFocus

Property CanAccessThis

CanAccessThis

Gets a value indicating whether code at the site can reference this. The value is false in static members, static lambdas, static local functions, field initializers, constructor initializers, and lambdas or local functions of struct members.

Declaration
bool CanAccessThis { get; }
Property Value
Type Description
bool
Remarks

When the value is true, a delegate that runs for the site, such as the delegate given to ForEachSite(Func<IMethodInterceptionSite, IMethodInterception>), gets the instance of the caller with This(), whose type is the declaring type of Member. When the value is false, This() throws an InvalidOperationException.