Effect of unused methods and properties on library or executable

前端 未结 3 775
广开言路
广开言路 2021-01-18 20:51

I\'m playing around with creating a source code generator for C# (.NET). Will generating properties or methods that never get called cause my code to run slower? How about i

3条回答
  •  我在风中等你
    2021-01-18 21:08

    Unused methods will make the executable slightly larger. It will take a bit longer to load, and will consume more system memory.

    If the application runs in a memory constrained environment you may see a slight reduction in performance.

    Aside from that, you should not see a performance slowdown.

    The "using" statements just allow you to write shorter versions of class names in your source code. They do not impact the file size or execution speed.

    There are third party linkers that can remove unreferenced methods from a final .EXE.

提交回复
热议问题