C # exclusive or operation

Source: Internet
Author: User

"^" Is an exclusive OR operator in C #. It can be understood as an exclusive operation.

The calculation rules are as follows:

Bytes --------------------------------------------------------------------------------------------------

True ^ false true

True ^ True False

False ^ true

False ^ False false

 

 

Only when one is true. Both are true and false.

 

Exclusive or operations can also be used as integers, such

 

Result of 5 ^ 12: 9

 

Because the difference or can only be based on two conditions: true and false, when an integer is exclusive or exclusive, the difference or

The binary value of 5 is 101.

The binary value of 12 is 1100.

Put them together

0101 (0 for irregular digits)

1100

Exception or result:

1001

 

1001 to 9 in decimal format

 

Related Article

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.