在C#中使用DeMorgan定理在条件语句中手动优化布尔表达式(例如if条件)是有用的, [英] Is it useful in C# to apply DeMorgan's theorem to manually optimize boolean expressions in conditional statements (e.g. if conditions)

查看:215
本文介绍了在C#中使用DeMorgan定理在条件语句中手动优化布尔表达式(例如if条件)是有用的,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

回到我在C和C ++中做大部分工作的那一天,当然,我会手动应用 deMorgan定理来优化任何非平凡的布尔表达式。

Back in the day when I did most of my work in C and C++, as a matter of course, I would manually apply deMorgan's theorem to optimize any non-trivial boolean expressions.

在C#中这样做是有用的, ?

Is it useful to do this in C# or does the optimizer render this unnecessary?

推荐答案

在处理器上这种快速,实际上不可能重新布置布尔表达式使速度有任何实际差异。而C#编译器是非常聪明的,它会优化它。优化可读性和清晰度!

On processors this fast, it's virtually impossible for rearranging boolean expressions to make any actual difference in speed. And the C# compiler is very smart, it will optimize it as well. Optimize for readability and clarity!

这篇关于在C#中使用DeMorgan定理在条件语句中手动优化布尔表达式(例如if条件)是有用的,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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