Is there a reason why extension methods cannot be called directly on "this"?

Possible duplicate:
Why can't you refer directly to extension methods?

Let's assume the following code:

public static class MyExtensions { public static void SayHello(this Foo self) {} } public class Foo { this.SayHello(); //this works SayHello(); //this does not compile } 

I'm just curious about this, why can't extension methods be used for implicit this ?

this.SayHello() and SayHello means the same when applied to instance methods. So, why use a different behavior when calling extension methods?

+4
source share

Source: https://habr.com/ru/post/1444556/


All Articles