Advantages to Using Private Static Methods

后端 未结 8 2302
南笙
南笙 2020-11-27 09:52

When creating a class that has internal private methods, usually to reduce code duplication, that don\'t require the use of any instance fields, are there performance or mem

8条回答
  •  离开以前
    2020-11-27 10:25

    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.

    src: MSDN - http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.110).aspx

提交回复
热议问题