Performance of using static methods vs instantiating the class containing the methods

后端 未结 8 1700
别跟我提以往
别跟我提以往 2020-11-30 07:31

I\'m working on a project in C#. The previous programmer didn\'t know object oriented programming, so most of the code is in huge files (we\'re talking around 4-5000 lines)

8条回答
  •  心在旅途
    2020-11-30 08:14

    It depends on what else that object contains -- if the "object" is just a bunch of functions then it's probably not the end of the world. But if the object contains a bunch of other objects, then instantiating it is gonna call all their constructors (and destructors, when it's deleted) and you may get memory fragmentation and so on.

    That said, it doesn't sound like performance is your biggest problem right now.

提交回复
热议问题