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 7033887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:07:09+00:00 2026-05-28T01:07:09+00:00

For discussion, I have this class with properties public class Intresting { decimal _mQty,

  • 0

For discussion, I have this class with properties

public class Intresting
{
   decimal _mQty, _mSpareQty;

   public Qty { get { return _mQty; } set { _mQty = value; } }
   public SpareQty { get { return _mSpareQty; } set { _mSpareQty= value; } }
   public SparePercentage
   { 
     get { return _mQty == 0 ?  0 : _mSpareQty / _mQty; }
     set { _SpareQty = Qty * value; }
   }
}

I am concern If I have 1,000,000 Interesting objects displayed in a custom GridView in a read only situation which shows SparePercentage via the property, the SparePercentage will be calculated over and over again or will there be optimised for example using a third _mSpareQtyPercentage which gets recalculated when Qty and SpareQty is set?

  • 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-28T01:07:10+00:00Added an answer on May 28, 2026 at 1:07 am

    I very much doubt that there’s anything in the JIT which would perform that optimization for you – after all, that requires more work each time Qty and SpareQty are set, and more space per object. That’s not a trade-off the JIT should be doing for you. You could do that yourself, of course – just don’t expect either the C# or JIT compiler to do it for you.

    I would expect the JIT compiler to inline your trivial properties – which can be written as automatically implemented properties as of C# 3:

    public decimal Quantity { get; set; }
    public decimal SpareQuantity { get; set; }
    

    (Note the changes to make the names more readable at the same time, by the way.)

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

Sidebar

Related Questions

I have entity class: public class Project { public virtual int Id { get;
I am asking this question for the discussion. Suppose i have flowing class hierarchy
I have the following code: public class OMyObject { public int Id { get;
We have this constant discussion in our project as to the granularity of our
This discussion started over here but I thought it would be nice to have
Inspired by the discussion in this question . We have all been taught that
I've seen a lot of discussion about this subject on here. If i have
I have a class called EditMapUtilities. Here are some class properties that I want
edit4: wikified, since this seems to have morphed more into a discussion than a
(This is a hypothetical question for discussion, I have no actual problem). Say that

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.