作者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