Is sa1200 All using directives must be placed inside the namespace (StyleCop) purely cosmetic? [duplicate]

纵饮孤独 提交于 2019-12-18 04:31:30

问题


Possible Duplicate:
Should Usings be inside or outside the namespace

sa1200 All using directives must be placed inside the namespace (StyleCop)

Is this just for code readibility or is there any actual advantage to doing so? Does it help the GC somehow?


回答1:


It definitely won't help with GC.

Here's the discussion about two styles:

http://blogs.msdn.com/abhinaba/archive/2006/08/21/709051.aspx

http://blogs.msdn.com/abhinaba/archive/2008/07/08/do-namespace-using-directives-affect-assembly-loading.aspx




回答2:


If you have multiple namespaces in your project, you can limit which namespaces are used by each one individually.

This might come in handy if there were class names in two different namespaces that were the same. One might be the default in one part of your project, while the other could be the default in another.

Yes they look for some really fringe cases for these rules.




回答3:


There is no runtime difference. It's purely a compile time (and development experience) change. The file, compiled IL will be identical in either case.



来源:https://stackoverflow.com/questions/1071797/is-sa1200-all-using-directives-must-be-placed-inside-the-namespace-stylecop-pu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!