启用C#优化代码时会导致问题 [英] When enabling c# optimize code cause issue

查看:95
本文介绍了启用C#优化代码时会导致问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个带值的浮动变量(值1 = 44.35和值2 = 44.35).

I have two floating variable with value (value1 = 44.35 and value2 = 44.35).

If(value1> value2)

If(value1 > value2)

//进行一些操作

未在Visual Studio中启用优化代码复选框,则此条件检查失败,将不执行任何操作.

Without enabling optimize code check box in visual studion this condition check failed and nothing will executed.

启用此属性后,即使执行失败也开始执行(使用鼠标悬停检查时显示为false).我可以知道原因吗?

When i enable this property then execution started even its failed (show as false when checking using mouseover). May i know the reason for these?

推荐答案

您好

Hi Vijay_RM,

/optimize选项启用或禁用由 执行的优化编译器来制作您的输出文件更小,更快,更高效.

The /optimize option enables or  disables optimizations performed by  the compiler to make your output file  smaller, faster, and more efficient.

在这里,我从引用 MSDN文档.

Here I referred from MSDN document.

默认情况下,对于 Debug 配置禁用优化的原因是,它使某些调试功能无法实现.一些值得注意的:

The reason optimization is disabled by default for Debug configurations is that it makes certain debugging features impossible. A few notable ones:

  • 最关键的是,编辑并继续功能被禁用-即在执行过程中没有修改代码.
  • 中断执行通常意味着高亮显示了错误的代码行(通常是预期值之后的值).
  • 未使用的局部变量实际上并未分配或声明.
  • Perhaps most crucially, the Edit and Continue feature is disabled - i.e. no modifying code during execution.
  • Breaking execution often means the wrong line of code is highlighted (usually the one after the expected one).
  • Unused local variables aren't actually assigned or even declared.

永远不要更改优化的默认选项.禁用调试选项非常有用,而将其用于发布模式则同样明智.

The default options for optimization never ought to be changed. Having the option off for debugging is highly useful, while having it on for Release mode is equally wise.

最诚挚的问候,

克里斯汀

 


这篇关于启用C#优化代码时会导致问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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