This post looks good to me. This is one of my favorite Razor tricks; I just wish you could do this in normal C# code!