Performance overhead for properties in .NET

前端 未结 9 1945
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 01:43

I read somewhere that having public properties is preferable to having public members in a class.

  1. Is this only because of abstaraction and modularity? Are

9条回答
  •  盖世英雄少女心
    2020-12-10 02:18

    I've asked the same question before.

    I'm guessing you're using VS2008, are using a 64-bit OS and have compilation set to "Any CPU"? If so, properties don't get inlined by the x64 JIT compiler. They do on 32-bit, making them identical in performance to public fields.

提交回复
热议问题