C# .NET: MVC Inline Functions and Writing to the Ouput

3/12/2014 10:33:25 PM

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 />");   
    }

}