Logical operators of asp.net operators and other operators, and asp.net operator Logic

Source: Internet
Author: User

Logical operators of asp.net operators and other operators, and asp.net operator Logic

The logical (boolean) operator is used to calculate the expression of the result of the boolean type. The result of the operation is boolean type. The calculation result is as follows:

Operator example result
& AND (AND) false & true false
| OR (OR) false | true
^ XOR (XOR) false ^ true
! NOT (NOT )! False true
& AND (Short Circuit) false & true false
| OR (Short Circuit) false | true


The following is a simple explanation of some problems:

1. "^" refers to the logic of the calculated operand "exclusive or". That is to say, the result is true only when only one operand is true.

2. the difference between "&" and "&" is that if the former is used for join, expressions on both sides of "&" are involved in calculation under any circumstances. If the latter connection is used, if the left side of "&" is false, the expression on the right side is not calculated. From: http://www.111cn.net/net/net/47469.htm

3. the difference between "|" and "|" is that "|" indicates that any Boolean expression on both sides is true, and true is returned for the combination. For "| ", similar to the second. If the left side is true, true is returned. If the left side is falsh, the right side is displayed. If the right side is true, true is returned. Otherwise, falsh is returned.

Example

The Code is as follows:
Using System;
Using System. Data;
Using System. Configuration;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;

Public partial class _ Default: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{

Int x = 0;
String name = "Search ";

// & Operation. If either of the two values is false, the operation is false.
Response. Write ("x! = 0 & name =/"Search/": "+ (x! = 0 & name = "Search "));

Response. Write ("<br> ");

// | Operation. If either of the two values is true, the operation result is true. Otherwise
Response. Write ("x! = 0 | name =/"Search/": "+ (x! = 0 | name = "Search "));

Response. Write ("<br> ");

// ^ Operation. if and only if one of them is True, the operation is True. Otherwise, the operation is false.
Response. Write ("x! = 0 ^ name =/"Search/": "+ (x! = 0 ^ name = "Search "));
Response. Write ("<br> ");
Response. write ("x = 0 ^ name =/" Search/"returns:" + (x = 0 ^ name = "Search "));
Response. Write ("<br> ");

(Www.111cn.net )//! Operation. If it is true, it is false. If it is false, it is true.
Response. Write ("x! The calculation result of = 0 is: "+! (X! = 0 ));

Response. Write ("<br> ");

// & Short circuit operation. If the left side is false, exit. If the left side is true, check the right side.
Response. Write ("x! = 0 & name =/"Search/": "+ (x! = 0 & name = "Search "));

Response. Write ("<br> ");
// | Short-circuit operation. If the left side is true, the system exits. If the left side is false, the system returns to the right side. If the right side is true, the system exits. Otherwise, the system returns false.
Response. Write ("x! = 0 | name =/"Search/": "+ (x! = 0 | name = "Search "));
}
}


Operator

C # provides a large number of operators that specify which operations are performed in the expression. You can perform integer operations on enumeration, such as = ,! =, <,>, <=,> =, Binary +, binary-, ^, &, | ,~ , ++, --, And sizeof (). In addition, many operators can be reloaded by users, thus changing the meaning of these operators when applied to user-defined types.

Operator category Operator
Basic x. y
F (x)
A [x]
X ++
X --
New
Typeof
Checked
Unchecked
->
RMB +
-
!
~
++ X
-- X
(T) x
True
False
&
Sizeof
Multiplication *
/
%
Addition +
-
Transform <
>
Link and type detection <
>
<=
> =
Is
As
Equal =
! =
Logic "and "&
Logic XOR ^
Logic "or" |
Conditions AND &&
Condition OR |
Conditional operation? :
Assignment =
+ =
-=
* =
/=
% =
& =
| =
^ =
<=
>>=
??

Operator priority
Front + + front -- + (positive)-(negative )! ~
*/%
+-
<>
<> <=> =
=! =
&
^
|
&&
|
Value assignment
Post ++ post --
Reload Operators
C # allows users to define types and use the operator keyword to define static member functions to overload operators. However, not all operators can be overloaded. The following table lists operators that cannot be overloaded:
Operator Overloading
+,-, And ,-,! ,~ , ++, --, True, and false can be used to reload these unary operators.
+,-, *,/, %, &, |, ^, <,> Can overload these binary operators.
= ,! =, <,>, <=,> = The comparison operator can be overloaded (but see the description below this table ).
&, | Conditional logical operators cannot be overloaded, but can be computed using the & and | that can be reloaded.
[] The array index operator cannot be overloaded, but the indexer can be defined.
() The conversion operator cannot be overloaded, but the new conversion operator can be defined (see explicit and implicit ).
+ =,-=, * =,/=, % =, & =, | =, ^ =, <=, >>= The value assignment operator cannot be overloaded, but + = Can Be Used + computing, and so on.
= ,.,? :,->, New, is, sizeof, and typeof cannot be overloaded.

Syntax
Public static Complex operator + (Complex c1, Complex c2)


What are the bitwise AND logical operators in C?

& Is logical and the logic of the computer is nothing more than two types. 0 and 0, 7 and 8 are both non-0, so 7 & 8 is not 0, which is true.
& Bitwise operation, that is, bitwise operations are performed based on the binary values of two operands.
The binary value of 7: 00000111
8 binary: 00001000
And after calculation: 00000000, the result is false.

What logical operators do?

Logic NOT
Logic AND
Logic OR
Priority: NOT AND OR
Operations of the same level from left to right

Run cmd, enter dos, enter cd \ to enter the directory of drive C, and then enter dir as the list of drive C files. enter cd windows to enter the windows folder. The input tree indicates the directory tree. enter D.
Use the find command for search, which is similar to windows Search.
Dir c: *. exe/B/syou can search all the. exe files on the c drive.
Syntax: find start Directory Search Condition operation

The following is the excerpt.
Find command

Function: Search for files in the directory structure and perform the specified operation. This command provides a lot of search conditions and is very powerful.

Syntax: find start Directory Search Condition operation

Note: The find command starts from the specified starting directory and recursively searches for each of its subdirectories to find and perform relevant operations on the files that meet the search criteria.

The search condition provided by this command can be a composite condition composed of logical operators not, and, or. Logical operators and, or, and not have the following meanings:

(1) and: logic and is represented by "-a" in the command. It is the default option of the system. It indicates that the search condition is satisfied only when all conditions are met. For example:

$ Find-name 'tmp '-xtype c-user 'inin'

This command is used to search for all files whose conditions are met.

(2) or: logical or, represented by "-o" in the command. This operator indicates that the search condition is satisfied as long as one of the given conditions is satisfied. For example:

$ Find-name 'tmp '-o-name 'mina *'

This command is used to query all objects whose names are 'tmp 'or match 'mina.

(3) not: Non-logical. Use "!" in the command. . This operator is used to search for objects that do not meet the given conditions. For example:

$ Find! -Name 'tmp'

This command is used to query all objects whose names are not 'tmp.

Note: When many logical options are used, you can enclose these options in parentheses. To avoid Shell misunderstanding, you must add the Escape Character "" before the phone number to remove the meaning of the brackets.

Example: $ find (-name 'tmp '-xtype c-user 'inin ')

The search condition has the following options:

First, the n value of each of the following options can be input in three ways, assuming n is 20, then:

+ 20: After 20 (, 22, 23, etc)

-20 indicates before 20 (19,18, 17, etc)

20 indicates that the value is 20.

1. Search by name and file attributes.

-Name 'string': searches for all files whose names match the given strings. Wildcards *,? ,〔〕.

-Lname 'string': searches for all symbolic link files of the given string matching the file name. Wildcards *,? ,〔〕.

-Gid n: searches for all files belonging to the user group with ID n.

-Uid n: searches for all files belonging to users with ID n.

-Group 'string': searches for all files belonging to the string given by the user group name.

-User 'string': searches for all files belonging to the string given by the user name.

-Nogroup: Find the file with no valid group, that is, the group to which the file belongs does not exist in/e t c/g r o u p s.
-Nouser: Find the file without a valid owner, that is, the owner of the file does not exist in/e t c/p a s w d.
-Newer file1! File2 searches for files whose change time is newer than file f I l e 1 but older than file f I l e 2.

-Empty: searches for directories or files with a size of 0.

-...... Remaining full text>

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.