What's the syntax of this route register statement
routes.Add(new Route("Catalog/{color}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(
new { controller = "Products", action = "List" }
)
});
I don't quite understand the above syntax, as far as i know, it adds a new route object to RouteTable.Routes collection, the Route o开发者_如何学JAVAbject has a constructor: Route(String, IRouteHandler), and a property 'Defaults' of 'RouteValueDictionary' type, but what's the syntax here, it looks like Object Initialization Expressions in c# 3.0, but it invokes the constructor, can anyone explain it a bit?
many thanks.
It is an object initialization expression, but those expressions can optionally include constructor parameters. Typically, when you see those initialization expressions, the default constructor is being used, in which case you don't need the parens after the new
.
精彩评论