In C # | (bit or) and | (logical or) What is the difference?

Source: Internet
Author: User
These two tips are different.
| During bitwise OR operations, the bitwise OR operator calculates the result of all operation conditions and determines whether the result is true.
| During logical or operation, if a previous or subsequent operation is established, the following conditions are no longer operated. Directly true.

The same is true.
Use & for example.
Txtname is a textbox.
If (txtname! = NULL & txtname. Text! = "")
{}
And
If (txtname! = NULL & txtname. Text! = "")
{}
Different results will appear.
When txtname = NULL.
An error is reported for 2nd statements.
Because the txtname will be executed together for the first 2nd! = NULL and txtname. Text! = ""
Therefore, an error is reported for 2nd conditions.
And execute txtname In the first sentence! = False when null
The execution will not continue.

 

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.