Looking at some code examples for HtmlHelpers, and I see declarations that look like:
public static string HelperName(this HtmlHelper htmlHelper, ...more reg
Extensions Methods...
...are a fantastic way to include functionality like if you where using the decorator pattern, but without the pain of refactoring all your code, or using a different name of a common type.
public static class Extensions
{
public static string RemoveComma(this string value)
{
if (value == null) throw new ArgumentNullException("value");
return value.Replace(",", "");
}
}
So you can use this code, anywhere in you app.
Console.WriteLine(“Hello, My, Friend”.RemoveComma())
>> Hello My Friend
So the this command attribute mean the type that the extension will be “added”, and let you work with the value as if it was passed as parameter.