I know you can overload an existing operator. I want to know if it is possible to create a new operator. Here\'s my scenario.
I want this:
var x =
I'm surprised no one mentioned "order of operations"
.
When the compiler evaluates an expression it has to be concerned with performing the operations in the correct order so that (1+2*3) = (2*3+1)
multiplication always happens before addition at the same "level"
in the expression.
When you override and operator, you can change what the operator does, but not the order in which the compiler will evaluate it. If you did created a new operator, there is no way to tell the compiler what order to evaluate it in relation to the others. So if you write x 2 + 5
Do you perform the x 2
first then add 5 or do you perform the addition first and then do x 7
.