简体   繁体   中英

Type alias or full namespace

Does it affect performance to use type alias rather than full namespace? For example, import just Form class using Form = System.Windows.Forms.Form; or import all types using System.Windows.Forms;

No this has absolutely no affect on the performance of your application. This could in theory have an affect on compilation time. But it would almost certainly be insignificant.

两者都没有完全一样的性能,只是个人喜好-它被编译为相同的代码。

绝对没有区别-编译器会在运行之前对其进行解析。

否。在运行时没有任何问题(生成的二进制文件是相同的),并且编译时的影响实际上可以忽略。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM