C# Extension Method for Object

后端 未结 6 1960
萌比男神i
萌比男神i 2021-02-06 22:22

Is it a good idea to use an extension method on the Object class?

I was wondering if by registering this method if you were incurring a performance penalty as it would b

6条回答
  •  轮回少年
    2021-02-06 23:08

    There will be no performance penalty as it doesn't attach to every type in the system, it's just available to be called on any type in the system. All that will happen is that the method will show on every single object in intellisense.

    The question is: do you really need it to be on object, or can it be more specific. If it needs to be on object, the make it for object.

提交回复
热议问题