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

  • SEARCH
  • Home
  • 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 3699426
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:06:05+00:00 2026-05-19T05:06:05+00:00

I have just been thinking about the concept of view model object we create

  • 0

I have just been thinking about the concept of view model object we create in asp.net MVC. Our purpose is to instantiate it and pass it from controller to view and view read it and display the data.

Those view model are usually instantiated through constructor. We won’t need to initialize the members, we may not need to redefine/override parameterless constructor and we don’t need inheritance feature there.

So, why don’t we use struct type for our view model instead of class. It will enhance the performance.

  • 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. Editorial Team
    Editorial Team
    2026-05-19T05:06:05+00:00Added an answer on May 19, 2026 at 5:06 am

    You take “it will enhance the performance” as a given, but are you really sure about this? Structs perform better than classes in very specific circumstances. I’m generalizing for simplicity, but the scenarios chiefly are:

    • They’re immutable.
    • They’re small, e.g. usually no more than 3 – 4 fields.
    • You’re generating tons (often millions or more) of them over an extremely short time span.
    • You’re working with them in tight loops.
    • The code paths that they travel through are optimized for those specific structs and do not perform boxing / unboxing operations.

    There are others, but that’s just off the top of my head. And even then, we’re talking about often minuscule performance gains. As in microseconds minuscule.

    Even if you can guarantee that your view models are immutable and tiny, the other conditions don’t hold. Assuming one view model per request, your web server is not going to handle millions of requests per second. Furthermore, the MVC framework does not work with these in tight loops and does not contain code paths optimized for this particular struct. The MVC framework will end up performing tons of boxing / unboxing operations on your value types as a result.

    Bottom line – don’t micro-optimize or over-engineer your solution. Classes are just fine. And when optimization is concerned, always measure to make sure you’re devoting your time to a worthwhile venture. Don’t bother with trivialities when there are bigger fish to fry.

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

Sidebar

Related Questions

Just something I have been thinking about. It is possible to create an android
Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I have been a .net developer for the past three yrs. Just curious to
This is just something I've been thinking about and was wondering if it exists,
I have been thinking and learning a lot about forms lately trying to add
I have been learning C# for the past few days for use with ASP.NET
I have just been re-working an old bit of compiler-like code written using bison.
I have just been getting into low level programming (reading/writing to memory that sort
OK, I have just been reading and trying for the last hour to import
I have just got a MacBook Pro and have been using it (+Fusion) to

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.