The accepted answer is good because it refers to a list of overloaded operators, but it does not strictly answer the question, because it does not provide operator names at compilation.
The answer to the second place includes this, but this is an incomplete list and not very organized. For completeness, I made my own list, including several statements that you might expect to be overloaded, but that is not the case. The list is in order of priority of the operator, from the highest (lowest) priority to the lowest.
Outside of Order of Operations (used when necessary to coerce types) op_Implicit op_True op_False Unary (only one operator) ++ op_Increment (Includes preincrement and postincrement) -- op_Decrement (Includes predecrement and postdecrement) - op_UnaryNegation + op_UnaryPlus ! op_LogicalNot ~ op_OnesComplement op_Explicit await (Not overloadable) Multiplicative / op_Division % op_Modulus * op_Multiply Additive + op_Addition - op_Subtraction Shift << op_LeftShift >> op_RightShift Relational > op_GreaterThan < op_LessThan >= op_GreaterThanOrEqual <= op_LessThanOrEqual as (Not overloadable) is (Not overloadable) Equality == op_Equality != op_Inequality And & op_BitwiseAnd Exclusive Or ^ op_ExclusiveOr Inclusive Or | op_BitwiseOr Conditional And && (Not overloadable - use "implicit operator bool" or "operator true") Contional Or || (Not overloadable - use "implicit operator bool" or "operator true") Null-Coalescing Operator ?? (Not overloadable) Ternary ?: (Not overloadable - use "implicit operator bool" or "operator true") Assignment = (Not overloadable - for combined operator and assignment (such as +=), just use the operator (+))
Note. The C # compiler prefers the implicit operator bool instead of the True and False operators, if both are defined.
As indicated by fooobar.com/questions/465918 / ... the following method names are also emitted / understood by the C # compiler, but
- I ran tests in Visual Studio 2015 and C # 6.0, trying to get them to work, and
- The C # 5.0 specification lists the "complete set of unary [and binary] operator function names" (Appendix A, p. 469), and they do not appear anywhere.
Unary & op_AddressOf * op_PointerDereference Binary . op_MemberSelection -> op_PointerToMemberSelection op_SignedRightShift op_UnsignedRightShift = op_Assign *= op_MultiplicationAssignment /= op_DivisionAssignment %= op_ModulusAssignment -= op_SubtractionAssignment += op_AdditionAssignment <<= op_LeftShiftAssignment >>= op_RightShiftAssignment |= op_ExclusiveOrAssignment &= op_BitwiseAndAssignment |= op_BitwiseOrAssignment op_UnsignedRightShiftAssignment op_SignedRightShiftAssignment , op_Comma
aboveyou00
source share