+ - ! ~ ++ -- true false[Note: Although true and false are not used explicitly in expressions, they are considered operators because they are invoked in several expression contexts: boolean expressions (§14.16) and expressions involving the conditional (§14.12), and conditional logical operators (§14.11). end note] 2 The overloadable binary operators are:
+ - * / % & | ^ << >> == != > < >= <=Paragraph 31 Only the operators listed above can be overloaded. 2 In particular, it is not possible to overload member access, method invocation, or the =, &&, ||, ?:, checked, unchecked, new, typeof, as, and is operators. Paragraph 41 When a binary operator is overloaded, the corresponding assignment operator, if any, is also implicitly overloaded. 2 For example, an overload of operator * is also an overload of operator *=. 3 This is described further in §14.13. 4 Note that the assignment operator itself (=) cannot be overloaded. 5 An assignment always performs a simple bit-wise copy of a value into a variable. Paragraph 51 Cast operations, such as (T)x, are overloaded by providing user-defined conversions (§13.4). Paragraph 61 Element access, such as a[x], is not considered an overloadable operator. 2 Instead, user-defined indexing is supported through indexers (§17.8). Paragraph 71 In expressions, operators are referenced using operator notation, and in declarations, operators are referenced using functional notation. 2 The following table shows the relationship between operator and functional notations for unary and binary operators. 3 In the first entry, op denotes any overloadable unary prefix operator. 4 In the second entry, op denotes the unary postfix ++ and --operators. 5 In the third entry, op denotes any overloadable binary operator. [Note: For an example of overloading the ++ and --operators see §17.9.1. end note]
Operator notation | Functional notation |
op x | operator op(x) |
x op | operator op(x) |
x op y | operator op(x,y) |
| |
Jagger Software Ltd | |
Company # 4070126 | |
VAT # 762 5213 42 |