3 ms·
Extension functions are syntax sugar for static methods that receive the class instance as this. They do not access private members. Also, you need to specific
by pennaMan 9y ago
Extension functions are syntax sugar for static methods that receive the class instance as this. They do not access private members.
Also, you need to specifically import the namespace of the extension function in order to use it, making it very clear to the reader of what is going on. It is not some hidden IDE magic, it's built into the core language.
- rubber_duck 9y agoI never said otherwise. I said it was misleading syntax sugar because it implies that static functions defined in any namespace (extension methods) are the same as methods - which have access to internal members and are defined within class hierarchy. If you know something is an extension method then you know it's just syntax sugar, but you can't determine that just by looking at the code.