Field vs Property. Optimisation of performance

后端 未结 6 1911
半阙折子戏
半阙折子戏 2020-12-08 06:20

Please note this question related to performance only. Lets skip design guidelines, philosophy, compatibility, portability and anything what is not related to pure performan

6条回答
  •  不知归路
    2020-12-08 06:42

    Have a look at the Properties vs Fields – Why Does it Matter? (Jonathan Aneja) blog article from one of the VB team members on MSDN. He outlines the property versus fields argument and also explains trivial properties as follows:

    One argument I’ve heard for using fields over properties is that “fields are faster”, but for trivial properties that’s actually not true, as the CLR’s Just-In-Time (JIT) compiler will inline the property access and generate code that’s as efficient as accessing a field directly.

提交回复
热议问题