Using C# Operators
C# provides several operators for arithmetic, logical, increment, decrement, and other operations. C# also provides for shorthand notations for common situations such as adding an amount to a variable. In addition, most of the C# operators can be overloaded by the developer. Overloading enables the developer to specify the behavior for the operator when applied to a specific type. Overloading will be covered later in this chapter. Table 3.1 provides a listing of all operators for C#.
Category | Operator | Description | Can Overload? |
---|---|---|---|
Arithmetic | + | Addition | Yes |
- | Subtraction | Yes | |
* | Multiplication | Yes | |
/ | Division | Yes | |
% | Modulus remainder | Yes | |
Logical | & | Bitwise AND | Yes |
| | Bitwise OR | Yes | |
^ | Bitwise exclusive OR | Yes | |
! | Logical negation | Yes | |
~ | Bitwise ... |
Get Microsoft® Visual C#® .NET 2003 Unleashed 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.