C# – How to define a method in Razor

asp.net-mvcasp.net-mvc-3crazor

How do I define a method in Razor?

Best Answer

Leaving alone any debates over when (if ever) it should be done, @functions is how you do it.

@functions {

    // Add code here.

}