+ 2
How can we have 1+1=0?
5 Answers
+ 15
one way would be to overload the operator + in int types to return 0 if both operands are 1,
but I don't know if it is possible to overload operators of builtin types in C#.
+ 14
here is an example using ruby:
https://code.sololearn.com/ct3LI8EutU2G/?ref=app
+ 5
If I am not mistaken, you will need to go down the road of operator overloading in c#.
You can redefine or overload most of the built-in operators available in C#. Thus a programmer can use operators with user-defined types as well. Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. similar to any other function, an overloaded operator has a return type and a parameter list.
Source: https://www.tutorialspoint.com/csharp/csharp_operator_overloading.htm
Check this as well for overloadable operators : http://stackoverflow.com/questions/6587107/c-sharp-operator-overload-for
Basically, you define a function in order to alter the use (way the operator works) of the operator.
+ 4
in base 2 (binary) one digit with no overflow
+ 2
Thanks for the response but we are speaking about c#.