Do C# static functions perform better than nonstatic functions, beyond reduced memory usage?

前端 未结 5 2032
太阳男子
太阳男子 2021-01-31 07:57

I assume that public or private static targets must have reduced memory usage, due to the fact that there is only one copy of the static t

5条回答
  •  粉色の甜心
    2021-01-31 08:53

    From Static Classes and Static Class Members (C# Programming Guide)

    A call to a static method generates a call instruction in Microsoft intermediate language (MSIL), whereas a call to an instance method generates a callvirt instruction, which also checks for a null object references. However, most of the time the performance difference between the two is not significant.

提交回复
热议问题