Content deleted Content added
mNo edit summary |
|||
Line 12:
As an example, consider a need of extending the string class with a new reverse method whose return value is a string with the characters in reversed order. Because the string class is a primitive type, the method would typically be added to a new utility class in a manner similar to the following:
<source lang="csharp">
string y = Utility.Reverse(x);
</source>
This may, however, become increasingly difficult to navigate as the library of utility methods and classes increases, particularly for newcomers. The ___location is also less intuitive because, unlike most string methods, it would not be a member of the string class, but in a completely different class altogether. A better syntax would therefore be the following:
<source lang="csharp">
string y = x.Reverse();
</source>
==Extension methods==
|