Vb.net-logical-operators
提供:Dev Guides
VB.Net-論理/ビット演算子
次の表は、VB.Netでサポートされているすべての論理演算子を示しています。 変数Aがブール値Trueを保持し、変数Bがブール値Falseを保持すると仮定します-
Operator | Description | Example |
---|---|---|
And | It is the logical as well as bitwise AND operator. If both the operands are true, then condition becomes true. This operator does not perform short-circuiting, i.e., it evaluates both the expressions. | (A And B) is False. |
Or | It is the logical as well as bitwise OR operator. If any of the two operands is true, then condition becomes true. This operator does not perform short-circuiting, i.e., it evaluates both the expressions. | (A Or B) is True. |
Not | It is the logical as well as bitwise NOT operator. Used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make false. | Not(A And B) is True. |
Xor | It is the logical as well as bitwise Logical Exclusive OR operator. It returns False if both expressions are True or both expressions are False; otherwise, it returns True. This operator does not perform short-circuiting, it always evaluates both expressions and there is no short-circuiting counterpart of this operator | A Xor B is True. |
AndAlso | It is the logical AND operator. It works only on Boolean data. It performs short-circuiting. | (A AndAlso B) is False. |
OrElse | It is the logical OR operator. It works only on Boolean data. It performs short-circuiting. | (A OrElse B) is True. |
IsFalse | It determines whether an expression is False. | |
IsTrue | It determines whether an expression is True. |
VB.Netで利用可能なすべての論理/ビット演算子を理解するために、次の例を試してください-
上記のコードをコンパイルして実行すると、次の結果が生成されます-