I had attended a great ASP.NET FireStarter session yesterday down at Infragistics HQ in West Windsor, NJ. Peter Laudati did a great job at presenting the material without making it seem like a marketing pitch. This was very refreshing, compared to other MS events.
One thing I took away from the meeting was an emphasis on the new Object Initializer. While this is not more than ‘syntactic sugar’, it does provide an easier way to set multiple properties simultaneously. (This will become more useful in the C# 4.0 timeframe with movement towards anonymous types – an extension of the theme of anonymous delegates, also known as lambda expressions)
While the MVC discussions were cursory in code, but deep in discussion and deserve longer blog posts than this, I saw an interesting quirk of the compiler. The following syntax is surprisingly valid (note the hanging comma on the last list element).
public class BlogController : Controller
{
public ActionResult PostList()
{
List<Post> posts = new List<Post>{
Post.GetPost(0),
Post.GetPost(1),
Post.GetPost(2),
Post.GetPost(3),
Post.GetPost(4),
};
// Add action logic here
return View();
}
}