Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 166251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:03:54+00:00 2026-05-11T12:03:54+00:00

While analyzing some ASP.NET MVC projects I got to see anonymous types scattered all

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:03:55+00:00Added an answer on May 11, 2026 at 12:03 pm

    IMHO, the biggest problems with anonymous types stem from the inability to name their type. That is, it’s not possible to expilictly specify the type of an anonymous type as an expression in code. This really makes in awkward to do things like create a generic List.

    var list = New List<No way to specify an Ananymous type>(); 

    Usually you have to resort to a helper method.

    public List<T> CreateList<T>(T notUsed) {   return new List<T>(); } var list = CreateList(new { .Class = 'foo' }); 

    This also has a larger impact in that you can’t use an anonymous type as a return type, makes casting extremely awkward (need a helper method), etc …

    But these are not the operations that Anonymous Types were designed for. In many ways they are designed to used within a particular defined function and it’s subsequently created lambda expressions. Not as a data communication type between to full fledged functions. This is certainly a limitation in the design and at times drives me batty. But overall I find them to be a very useful construct in the language.

    Many parts of LINQ would not be possible without them in some form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 75k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer This is not 'implementation defined' by the Standard, this is… May 11, 2026 at 2:37 pm
  • added an answer FxCop can perform static analysis of compiled assemblies, ReSharper can… May 11, 2026 at 2:37 pm
  • added an answer Lump in #apache on freenode helped me out. RewriteCond %{HTTP_HOST}… May 11, 2026 at 2:37 pm

Related Questions

So I have a nasty stack overflow I have been trying to track down
I'm using 3.5 SP1 on my machine, while our customers currently use 3.5 without
Any personal experience in overcoming web application performance hurdles? Any recommended strategies for improving
I've been thinking a while about disallowing every crawler except Ask, Google, Microsoft, and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.