In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about the specific .net operators and basic sentences. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.
.net operator
Operator
C # provides a large number of operators, which are symbols that specify what to do in an expression. Integer operations on enumerations are usually allowed, such as = =,! =, =, binary +, binary -, ^, &, |, ~, + +,--, and sizeof (). In addition, many operators can be overloaded by the user, thus changing the meaning of these operators when applied to user-defined types.
Operator class operator
Basic
X.y
F (x)
A [x]
Xerox +
Xmuri-
New
Typeof
Checked
Unchecked
->
One yuan
+
-
!
~
+ + x
-- x
(t) x
True
False
&
Sizeof
Multiplication
*
/
%
Addition
+
-
Transform
Relationship and type detection
=
Is
As
Equal
= =
! =
Logical "and"
&
Logical XOR
^
Logical OR
| |
Conditional AND
& &
Conditional OR
| | |
Conditional operation
?:
Assignment
=
+ =
-=
* =
/ =
% =
& =
| =
^ =
=
??
Operator precedence
Front + + front-+ (positive sign)-(negative sign)! ~
* /%
+-
>
< >=
=! =
&
^
| |
& &
| | |
Assignment operation
After + +--
Reloadable 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, and the following table lists operators that cannot be overloaded:
Operator reloadability
+, -,!, ~, +,--, true and false
These unary operators can be overloaded.
+, -, *, /,%, &, |, ^
These binary operators can be overloaded.
=,!, =
Comparison operators can be overloaded (but see instructions later in this table).
& &, | |
Conditional logic operators cannot be overloaded, but can be calculated using & and |, which can be overloaded.
[]
The array index operator cannot be overloaded, but indexers can be defined.
()
Conversion operators cannot be overloaded, but new conversion operators can be defined (see explicit and implicit).
+ =,-=, *, /,% =, & =, | =, ^ =, =
Assignment operators cannot be overloaded, but + = can be calculated using +, and so on.
=,.,?:,->, new, is, sizeof and typeof
These operators cannot be overloaded.
Grammar
Public static Complex operator + (Complex C1, Complex c2)
.net basic statement
Branch statement
Ternary operator
(.) ? b:c
How to take a value when the value may be empty
(s = = null)? ": s
If else statement
If () {} else if () {} else {}
Switch statement
Switch (var) {case:. Break; default:... Break;}
Iterative statement
Do/while cycle
Do {. } while ()
While cycle
While () {. }
For cycle
For (;) {. }
Foreach,in cycle
Foreach (in) {. }
Jump statement
Break
Terminate the cycle immediately
Continue
End the current loop and move on to the next loop
Goto
Jump out of the loop to the mark position
Goto;
Return
Jump out of the loop and end the method that contains it
Exception block statement
Throw
The throw statement is used to signal that an abnormal condition (exception) occurs during program execution.
Try-catch
The try-catch statement consists of a try block followed by one or more catch clauses that specify different exception handlers and specify that general exception handling uses catch {.}.
Try-finally
The finally block is used to clear any resources allocated in the try block and to run any code that must be executed even if an exception occurs. Control is always passed to the finally block, regardless of how the try block exits.
Try-catch-finally
A common way to use catch with finally is to get and use resources in try blocks, handle exceptions in catch blocks, and release resources in finally blocks.
Try {checked {. }} catch (OverflowException ex) {. }
Overflow monitoring statement
Checked
Test whether a numerical type overflows when doing arithmetic operations, and gets an exception System.OverflowException when it overflows
Unchecked {. } these are the specific .net operators and basic statements, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.