问题
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