Chapter 8. Operators

Any programming language provides a base set of operators and expressions. Depending on the richness of the set of operators and expressions, your code can end up looking either verbose or terse. Associated with operators is also the context in which the operator is being used. This context is usually supplied by the operand. For example, an operator can behave differently depending on whether the operand is numeric or nonnumeric. Many languages allow an operator to behave differently depending on the context in which it is being used, a behavior called operator overloading. Although Java does not allow the programmer to overload operators, C# does, and you will see how you can use this feature to your advantage in writing clean code. Table 8.1 lists the C# operator categories and the operators associated with each category.

C# operators can be unary (requiring one operand), binary (requiring two operands), or ternary (requiring three operands). The latter category includes only one operator, ?:.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.45.162