logical operators for C #

Source: Internet
Author: User

The C # language provides three kinds of logical operators:

&& Logic and

| | Logical OR

! Logical Non

Where logic and logic or both are two-element operators, require two operands. The logic is not a unary operator, only one operand. Their operands are all Boolean-type values or expressions. When operands are in different combinations, the results of the logical operators can be expressed in the "truth table" of logical operations, as shown in tables 7-6:

Table 7-6 Truth Tables

A B !a A&&b a| | B
True True False True True
True False False False True
False True True False True
False False True True False

If there are multiple logical operators in the expression at the same time, logical non precedence is highest, logical and precedence over logic or.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.