I’ve just come across the following code which I can’t understand:
var dataItem = (SportNode)item.DataItem;
item.FindControl<Literal>("Node", image =>
image.Text = string.Format("<li data-nodeId='{1}' class='{0}'><a href='/sport?navItems={3}'>{2}</a></li>", "top",
dataItem.NodeId, dataItem.Text, dataItem.NodeId));
In particular, where does image come from? It’s not declared anywhere yet seems to have a type. I certainly can’t see it in any parent classes.
“image” is the input parameter to the lambda expression.
Read more on lambdas here.
For a more readable and in-depth look at lambdas, Scott Guthrie has a great post introducing them.