C#如何计算不带括号的AND OR表达式 [英] How does C# evaluates AND OR expression with no brackets

查看:55
本文介绍了C#如何计算不带括号的AND OR表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定这是否完全有意义我试图了解C#如何处理以下逻辑

not sure if this make sense at all im trying to understand how C# process the following logic

false && true || false
false || true && false

基本上,我试图找出没有括号时C#如何评估这些表达式.

basically i'm trying to find out how C# evaluate these expression when there is no parentheses .

推荐答案

由于标准指定也就是说,如果一个表达式要求您思考序列中发生的事情多于一秒钟,请使用括号将其弄清楚=)

That said, if an expression requires you to think for more than a second about what is happening in what sequence... use parentheses to make it clear =)

这篇关于C#如何计算不带括号的AND OR表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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