While analyzing some ASP.NET MVC projects I got to see anonymous types scattered all over.
HTML helpers have them:
<%=Html.TextBox("view.Address", "address", new { Class = "text_field" })%>
A lot of the return types for actions have them:
JsonNetResult jsonNetResult = new JsonNetResult
{
Formatting = Formatting.Indented,
Data = new {Something= “”}
}
I know this came from LINQ:
from p in context.Data
select new { p.Name, p.Age };
Are these really the correct way to accomplish things now outside of LINQ? Do they hurt code reusability and readability?