[英]C# and VB.NET operator precedence
Looking at the C# and VB.NET language specs I think it says that the logical Xor/Or/And operations have different precendence in the two languages.查看 C# 和 VB.NET 语言规范,我认为它说逻辑 Xor/Or/And 操作在两种语言中具有不同的优先级。 Am I reading that right?
我读对了吗? I was expecting them to have the same precendence.
我期待他们有同样的优先权。
For example in C#例如在 C# 中
100 | 200 ^ 300 & 400
is the same as...是相同的...
100 | (200 ^ (300 & 400))
But the equivalent VB.NET但等效的 VB.NET
100 Or 200 Xor 300 And 400
as far as I can tell is the same as...据我所知是一样的......
(100 Or 200) Xor (300 And 400)
Am I reading that right?我读对了吗?
Personally, I'm not a fan of remembering precedence rules.就个人而言,我不喜欢记住优先规则。 If there is any ambiguity, I just add brackets.
如果有任何歧义,我只是添加括号。 Even if I get it right, somebody else might have to read it, and I don't know which background they'll have...
即使我猜对了,也可能会有人阅读它,我不知道他们会有什么背景......
But I think you are reading it correctly.但我认为你读对了。
Am I reading that right?
我读对了吗?
Yes.是的。 Simple as that.
就那么简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.