c# - Why is the "this" pointer null in a delegate? -


I have the following code (details have been removed for clarity):

  Private primate class base & lt; TResult & gt; {Private Redoni system.fanks & lt; TResult & gt; Func = null; Protected Base (System.Func & lt; TResult & gt; func) {this.func = func; } Public Tresult Execute () {return.func (); }} Private class created: base & lt; Bool & gt; {Bool myValue): Base (Representative ()) This Return MyValue ();}) {this.myValue = myValue; } Private bool myValue = false; Private Bull Live () {return.myValue; // "this" indicator is empty here ...}} derived d = new received (true); Bull results = d.Execute (); // This results in an empty reference indicator (commented on)  

Any thoughts?

Thanks, Dave

Is this also legal is? This is not defined at that point. IIRC, this is a compiler bug - fixed in 4.0.

Here is the 4.0 compiler:

Error 1 keyword 'this' is currently not available Reference C: \ Users \ Marc \ AppData \ Local \ Temporary Projects \ ConsoleApplication1 \ Programs.cs 22 40 ConsoleApplication1

7.5.7 Excerpt:

This access is permitted only in the block of an instance constructor , Is an example method or an example accessor. It has one of the following meanings:

(emph mine)

...

It is used primarily- Exception in other context is a compile-time error, in particular, it is not possible to mention it in a static method, a static property accelerator or variable-declaration of field declaration.

In the given example, this is simply invalid.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -