在C#中优化代码有风险吗? [英] Are there risks to optimizing code in C#?

查看:201
本文介绍了在C#中优化代码有风险吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS2010 Pro的构建设置面板中,有一个带有标签优化代​​码的复选框...当然,我想检查它...但是异常谨慎,我问我的哥哥关于它和他说它是未经检查的调试,在C + +它可能会做的事情,会破坏或错误的代码...但他不知道C#。

In the build settings panel of VS2010 Pro, there is a CheckBox with the label "optimize code"... of course, I want to check it... but being unusually cautious, I asked my brother about it and he said that it is unchecked for debugging and that in C++ it can potentially do things that would break or bug the code... but he doesn't know about C#.

所以我的问题是,我可以检查这个框,我的发布版本,而不必担心它打破我的代码?二,如果可以破解代码,什么时候为什么?欢迎链接到解释。

So my question is, can I check this box for my release build without worrying about it breaking my code? Second, if it can break code, when and why? Links to explanations welcome.

推荐答案

通常在发行版中使用这个选项。它是安全和主流这样做。没有理由担心发布启用了优化的代码。启用优化可能会干扰调试,这是禁用调试版本的好理由。

You would normally use this option in a release build. It's safe and mainstream to do so. There's no reason to be afraid of releasing code with optimizations enabled. Enabling optimization can interfere with debugging which is a good reason to disable it for debug builds.

这篇关于在C#中优化代码有风险吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆