Problem with c# constructors
Using Asp.Net-MVC music store tutorial, concrete page is at :
http://www.asp.net/mvc/tutorials/mvc-music-store-part-3
<ul>
@foreach (var genre in Model)
{
<li>
@Html.ActionLink(genre.Name,"Browse", new { genre = genre.Name })
</li>
}
</ul>
Variable genre is reference for Object created in Controller Class which has one property - Name, and i can't menage to understand this new{genre=genre.Name}
instantiation-assignment. Can someone give me a link or explanation开发者_C百科 of this language feature?
It is an object initializer, creating an anonymous type.
In this case, the anonymous type has a genre
string property, initialized to the enclosing genre.Name
property.
The naming in this code sample is a bit poor and can be confusing.
That looks like Anonymous type.
精彩评论