What are the performance implications of marking methods / properties as virtual?

后端 未结 7 1275
别那么骄傲
别那么骄傲 2020-12-04 14:06

Question is as stated in the title: What are the performance implications of marking methods / properties as virtual?

Note - I\'m assuming the virtual methods will <

7条回答
  •  -上瘾入骨i
    2020-12-04 14:45

    From your tags, you're talking c#. I can only answer from a Delphi perspective. I think it will be similar. (I am expecting negative feedback here :) )

    A static method will be linked at compile time. A virtual method requires a lookup at run-time to decide which method to call, so there is a small overhead. It is only significant if the method is small and called often.

提交回复
热议问题