I am currently creating some special helper classes similar to the ASP.NET MVC standard HtmlHelper. When I looked for implementation HtmlHelper, I noticed that most / all HTML generation methods (such as ActionLink(), BeginForm(), TextBox()etc.) are not implemented directly within HtmlHelper class, but as extension methods in separate classes (e.g., class LinkExtensions).
Besides organizing your source code better, is there any advantage to implementing methods such as extension methods instead of regular methods?
When creating my own helper classes, should I also follow this pattern?
Update : when I wrote that I wanted to create my own helper class, then I wanted to extend the existing HtmlHelper class. Instead, I created a custom base class for my views (derived from ViewPage), and I want to add an additional helper class there, similar to the Html and Url helper classes for ViewPage.
source
share