+ 2

How can we have 1+1=0?

24th Apr 2017, 12:18 AM
Mohamed Khalil NASRALLAH
Mohamed Khalil NASRALLAH - avatar
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#.
24th Apr 2017, 12:39 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 14
24th Apr 2017, 12:44 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 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.
24th Apr 2017, 12:42 AM
Billy Tsouvalas
+ 4
in base 2 (binary) one digit with no overflow
24th Apr 2017, 12:21 AM
⏩▶Clau◀âȘ
⏩▶Clau◀âȘ - avatar
+ 2
Thanks for the response but we are speaking about c#.
24th Apr 2017, 12:23 AM
Mohamed Khalil NASRALLAH
Mohamed Khalil NASRALLAH - avatar