作者SUZUKI1127 (我要玩五子棋)
看板Visual_Basic
标题[.NET] or and的写法
时间Sun Oct 14 13:44:55 2007
在VB.NET里
假设两段判断式:
1. if a and b then
...
2. if a and c then
...
可不可以写成
if a and b or c then
..
还有 if x>y and i>j then
的 x>y i>j 要不要()--> (x>y) (i>j)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.72.0.201
※ 编辑: SUZUKI1127 来自: 203.72.0.201 (10/14 13:49)
1F:推 fumizuki:你的目标是 a and b and c 还是 a and (b or c) ??? 10/14 17:28
2F:推 fumizuki:比较运算子 > = < >= <= <> 的优先等级比逻辑运算子大 10/14 17:29
3F:推 fumizuki:所以不需要加() 10/14 17:31
4F:→ fumizuki: 12-1-6-4 有说明 10/14 17:32
5F:推 SUZUKI1127:目标是 a and (b or c) 10/14 23:19
6F:→ SUZUKI1127:再问 a and b and c 这样的写法 是ok的吗? 10/14 23:22
7F:推 fumizuki:a and b and c = (a and b) and c 10/15 07:12
8F:→ fumizuki:运算的先後顺序是由左至右 以结果论 a and b and c 10/15 07:12
9F:→ fumizuki:abc三者皆为 True 的时候 条件式成立 10/15 07:13