Updated on Kisan Patel
Sometimes, we need to create a custom helper method in the Razor to avoid the duplication of the code. To do that we can use @helper
markup followed by the name of the method and parameters if any.
@helper Sum(int a, int b) { <b>@(a + b)</b> }
To call this helper method, we can call it as if it is any other method defined in Razor server side block.
<li>Inline Helper Method Output: @Sum(10, 30)</li>