本文介绍了是否有消除不必要的命名空间(用)指令性能提升?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不要紧,使用编译器指令有多少人在我的课?有没有删除那些不必要的性能提升?

Does it matter how many using compiler directives are in my classes? Is there a performance gain in removing those that aren't necessary?

虽然我喜欢写代码精简,有时,代码段被修改,并且没有机会回去检查是否所有包含命名空间真的是必要的。或者,我不回去,并删除那些自动插入由Visual Studio

Although I enjoy writing streamlined code, on occasion, code segments get modified, and don't have the opportunity to go back and check to see if all of the included namespaces are really necessary. Or, I don't go back and remove those that are auto-inserted by visual studio.

如:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;



谢谢!

Thanks!

推荐答案

没有,有没有性能上的优势。

No, there's no performance advantage.

编译器不使用语句产生白细胞介素(可执行代码)。 IL是只对那些类,方法调用等,能充分利用您提供的使用语句生成的。

The compiler doesn't generate IL (executable code) for using statements. IL is only generated for those classes, method calls, etc. that take advantage of the using statements you provide.

因此,唯一的作用未使用使用语句可能是略有增加您的构建时间,或者使接下来的开发人员,你知道后,为什么他们在那里。

Consequently, the only effect unused using statements might have is to slightly increase your build time, or make the next developer after you wonder why they are there.

这篇关于是否有消除不必要的命名空间(用)指令性能提升?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 16:58