by luisabreu via LA.NET [EN] on 3/11/2010 1:46:08 PM
I’m back…I hope…After some complicated times which culminated in the floods which destroyed several regions of Madeira, I guess things are starting to coming back to normal…at least, that’s what I hope…I’ll probably return to blogging, though the rhythm won’t be the same as before.
One of the things I’ve been doing since I’ve migrated my code to C# 3.0 is defining and using extension methods. Another things which I tend *not* to do is use the this for qualifying access to a class’ members. Now, the thing is that *this* is required (ie, not optional) when you want to use an extension method in a class’ body. Suppose you’ve got class A and an extension method called T. Take a look at the following snippet:
class A { public void DoSomething() { this.T(); } }
Since T is an extension method, you do really need to use the *this* qualifier. If you don’t, you’ll end up with a compiler error. I guess this is one of the oddities associated with extension methods (after all, they’re really static methods and we’re talking about a hack which does really help in several scenarios)…
Original Post: Extension methods oddities
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.