In fact, we’ve taken great pains to ensure that the experience of calling an extension method on an object is as smooth as possible. The compiler will then emit code that is equivalent to the following:įor the most part this transformation is simple and automatic. Sub Times( ByVal x As Integer, ByVal d As DelegateSub) Essentially, whenever the compiler detects a call to an extension method, it simply translates it into a call to the underlying module method, passing in the call’s receiver as the method’s first argument. Today I’m going to talk about some perils to be aware of when defining extension methods.įirst, however, I’m going to dig a little into the mechanics used by the compiler for evaluating extension method calls. In my previous 2 posts I talked about some of the benefits of extension methods and then delved into the details of our new binding rules for consuming them in your programs.
0 Comments
Leave a Reply. |