Actual Performance of Fields vs. Properties

前端 未结 3 1580
慢半拍i
慢半拍i 2020-12-11 04:01

I\'m doing some post-build CIL weaving that adds CIL to all methods in an assembly (in other words tons of methods). Each method checks if a specific value is null. Example

3条回答
  •  温柔的废话
    2020-12-11 04:33

    The C# compiler won't optimize this, no - but the JIT compiler can usually inline trivial (and non-virtual) properties as far as I'm aware.

    As with all performance questions though: when in doubt, test!

提交回复
热议问题