In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "ASP.NET logical operators what", in daily operation, I believe many people in ASP.NET logical operators what problems there are doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "ASP.NET logical operators what" doubts helpful! Next, please follow the small series to learn together!
Logical (Boolean) operators are used to operate on expressions with boolean results, which are boolean. The result is as follows:
Operator Example Results
& AND false&true false
| OR(or) false| true true
^ XOR false^true true
! NOT! false true
&& AND(short circuit) false&&true false
|| OR(short circuit) false|| true true
Here is a brief explanation of some of the more common problems:
"^" evaluates the logical XOR of the operands; that is, the result is true if and only if one of the operands is true.
The difference between "&" and "&&" is that if the former is used, then in any case, the expressions on both sides of "&" will participate in the calculation. If the latter concatenation is used, the expression to the right of the & will not be evaluated when the left of the & is false.
3、"|"And."||"The difference is,"|"indicates that either Boolean expression on both sides is true, and the combination returns true; for"||", similar to the second, returns true if left is true, looks right if left is falsh, true if right is falsh otherwise falsh.
cases
The copy 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, false if either is false
Response.Write("x != 0 & name = /"search bar/" operation results in: "+ (x != 0 & name == "Search");
Response.Write("
");
//|An operation that is true when either of the two is true; otherwise, it adds.
Response.Write("x != 0 |name = /"search bar/" operation results in: " + (x != 0 |name == "Search it");
Response.Write("
");
//^operations are true if and only if one is True, otherwise false
Response.Write("x != 0 ^ name = /"search bar/" operation results in: " + (x != 0 ^ name == "Search it");
Response.Write("
");
Response.Write("x == 0 ^ name = /" search bar/");
Response.Write("
");
//! arithmetic, if true then false, if false then true
Response.Write("x != The result of 0 is: " + ! (x != 0));
Response.Write("
");
//&& Short circuit operation, if left is false, exit, if left is true, look at right
Response.Write("x != 0 && name = /"search bar/" results in: " + (x != 0 && name == "Search");
Response.Write("
");
//||Short circuit operation, if the left is true, then true exit; if the left is false, then look at the right, the right is true, otherwise false
Response.Write("x != 0 ||name = /"search bar/" operation results in: " + (x != 0 ||name == "Search it");
}
}
operator
C#provides a number of operators, which are symbols that specify what operations are performed in expressions. Integer operations are usually allowed on enumerations, e.g.==,!=,=, binary +、binary -、^、&、|,~,++, --, and sizeof(). In addition, many operators can be overloaded by the user, thereby changing the meaning of these operators when applied to user-defined types.
operator class operator
Basic x.y
f(x)
a[x]
x++
x--
new
typeof
checked
unchecked
->
One dollar +
-
!
~
++x
--x
(T)x
True
False
&
sizeof
Multiplication *
/
%
addition +
-
transform>
Relationship and type detection
< >=
is
as
Equal ==
!=
logical AND &
Logical XOR ^
logical OR|
Condition AND &&
conditional OR||
Conditional operation?:
assignment =
+=
-=
*=
/=
%=
&=
|=
^=
=
??
operator precedence
Front ++ Front-- +(plus)-(minus)! ~
* / %
+ -
>
< >=
== !=
&
^
&&
assignment
After ++ After--
overloaded operator
C#allows user-defined types to overload operators by defining static member functions using the operator keyword. However, not all operators can be overloaded. The following table lists operators that cannot be overloaded:
operator overloading
+、-、!、~、++、--、True and false overload these unary operators.
+, -, *, /, %, &, |These binary operators can be overloaded.
==, !=, , = The comparison operator can be overloaded (see the description later in this table).
&&, ||Conditional logical operators cannot be overloaded, but you can use & and which can be overloaded| to do the calculations.
[] Array index operators cannot be overloaded, but indexers can be defined.
() cannot overload conversion operators, but you can define new conversion operators (see explicit and implicit).
+=, -=, *=, /=, %=, &=, |=, ^=, = assignment operators cannot be overloaded, but += can be evaluated with +, and so on.
=、.、?:、->、new, is, sizeof, and typeof cannot overload these operators.
syntax
The copy code is as follows:
public static Complex operator +(Complex c1, Complex c2)
At this point, the study of "what are the logical operators of ASP.NET" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.