While this is not recommended, you can create inline functions within you Razor view. You could also use an inline function to output something to page.
@functions
{
public void DoSomething(int num, string strValue)
{
string something = "Do Something: " + num.ToString() + " - " + strValue;
WriteSomething(something);
}
public void WriteSomething(string something)
{
Response.Write(something + "<br />");
}
}