Operators
C# supports the usual logical and arithmetic operators in addition to a few others. Table A.2 briefly describes the operators supported by C#.
Operator(s) | Description | Overloadable |
---|---|---|
& | Logical AND | Yes |
^ | Logical XOR | Yes |
| | Logical OR | Yes |
&& | Conditional AND | No |
|| | Conditional OR | No |
?: | Conditional | No |
=, *=, /=, %=, +=, -=,<<=, >>=, &=, ^=, and |= | Assignments | No |
new | Object creation | No |
() | Cast | No |
true or false | Boolean | Yes |
. | Member access | No |
++ | Increment | Yes |
-- | Decrement | No |
sizeof, typeof, and is | Type information | No |
+, -, *, /, and % | Arithmetic | Yes |
==, >=, <=, !=, >, and < | Relational | Yes |
Comparison operators can be overloaded only in pairs. For example, if the == operator is overloaded, the != operator must also be overloaded. ...
Get Building e-Commerce Sites with the .NET Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.