Going from ASP.NET 2.0 (VB) to MVC 3 (C#), I’m very confused about the syntax being used for the View.
@Html.LabelFor(m => m.UserName)
Where did that m come from? My only guess is that it represents the model that is being passed into the view. I tried changing the m to c and it still works fine.
Is the part of the syntax that involves the “=>” more of a MVC, C#, or Razor element?
It’s the parameter in a lambda expression.
That’s because the name doesn’t matter. It’s just a parameter name, it doesn’t actually refer to any existing variable.
It’s C#, but
LabelForuses what the compiler translatesm => m.UserNameinto to extract what it needs to build up the label.This is a very deep an intricate subject. I suggest that you find a book that you’re comfortable with (e.g., C# in Depth is very good on this subject) to understand more. You want to read about lambda expressions and expression trees.