C # logical operators

Source: Internet
Author: User

One, C # logical operators

The logical operator of the C # language is to compare the value of a variable, the result of an expression, and the result of a base comparison is true or false.

Ii. examples

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;

Namespace Test
{
Class Program
{
static void Main (string[] args)
{
C # logical operator-www.baike369.com
Console.WriteLine ("With Operator:" + (1 > 2 & 2 < 3)); Comparison of BOOL Types
Console.WriteLine ("Or Operator:" + (1 > 2 | 2 < 3));
Console.WriteLine ("Xor Operator:" + (1 > 2 ^ 2 < 3));
Console.WriteLine ("Logical Non-operator:" +! ( 1 < 2));
Console.WriteLine ("Logical AND Operator:" + (1 > 2 && 2 < 3));
Console.WriteLine ("Logical OR Operator:" + (1 > 2 | | 2 < 3));
Console.ReadLine ();
}
}
}

Operation Result:

With operator: False
Or operator: True
Xor Operator: True
Logical non-operator: False
Logic and operators: False
Logical OR Operator: True

C # logical operators

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.