Why remove unused using directives in C#?

后端 未结 10 1683
猫巷女王i
猫巷女王i 2020-11-30 20:10

I\'m wondering if there are any reasons (apart from tidying up source code) why developers use the \"Remove Unused Usings\" feature in Visual Studio 2008?

10条回答
  •  無奈伤痛
    2020-11-30 20:16

    There are a few reasons you'd want to take them out.

    • It's pointless. They add no value.
    • It's confusing. What is being used from that namespace?
    • If you don't, then you'll gradually accumulate pointless using statements as your code changes over time.
    • Static analysis is slower.
    • Code compilation is slower.

    On the other hand, there aren't many reasons to leave them in. I suppose you save yourself the effort of having to delete them. But if you're that lazy, you've got bigger problems!

提交回复
热议问题