Content deleted Content added
Restoring versioning problem section. If you disagree, let's discuss it on the talk page. I don't believe this problem with extension methods is well-known. I'm happy for you to revise wording etc. |
|||
Line 23:
</source>
===Extension methods===
The new language feature of extension methods in C# 3.0, however, makes the latter code possible. This approach requires a static class and a static method, as follows:
<source lang="csharp">
Line 39:
The major difference between extension methods and normal, static helper methods is that static methods calls are [[Polish_notation|prefix notation]], whereas extension methods calls are in [[Infix_notation|infix notation]]. This leads to more readable code when the result of one operation is used for another operation.
;With static methods: <source lang="csharp">HelperClass.Operation2(HelperClass.Operation1(x, arg1), arg2)
;With extension methods: <source lang="csharp">x.Operation1(arg1).Operation2(arg2)
In the current implementation, a member method with the same name as an extension method shadows the latter and makes it inaccessible. The IDE ([[Microsoft Visual Studio|Visual Studio]]) also does not warn about the naming conflict.
==See also==
|