How do I define a method in Razor?
Leaving alone any debates over when (if ever) it should be done, @functions is how you do it.
@functions { // Add code here. }