gpt4 book ai didi

c# - 引用许多程序集是否有负面影响?

转载 作者:行者123 更新时间:2023-11-30 14:34:37 27 4
gpt4 key购买 nike

引用许多程序集的负面影响是什么?我注意到 ReSharper 具有“删除未使用的引用”的能力(尽管有时它是错误的,例如当依赖于引用的程序集在运行时通过 Ninject 加载时),但是除了让项目看起来更干净之外还有什么好处吗?生成的程序集在运行时会占用更少的内存吗?也许编译器足够聪明,可以注意到未使用的引用?

最佳答案

编译器足够聪明,可以忽略任何未使用的引用。

但是,Visual Studio Intellisense 中引用的许多程序集会对性能产生影响。

来自 C# Team's FAQ Blog on MSDN

Given that the .NET platform encourages binary reuse of types, it is commonplace to set references to external assemblies using the Visual Studio .NET Add Reference dialog box. Many programmers (especially those of the C(++) ilk) fear that adding unnecessary external references can result in a bit of 'code bloat'. Nothing could be further from the truth. When you add assembly references or make use of the 'using' keyword, csc.exe will ignore any assembly which you have not actually made use of in your code.

关于c# - 引用许多程序集是否有负面影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13689215/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com