Extension method: Difference between revisions

Content deleted Content added
Line 25:
==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">
 
public static class Util
{
public static string Reverse(this string input)
{
char[] chars = input.ToCharArray();
Array.Reverse(chars);
return new String(chars);
}
}
</source>
 
==Related==