It depends on what a is. We could create a class so that it can behave as shown above. We need to overload the operators' == 'and'! = '.
class StrangeInt { public static bool operator ==(StrangeInt obj1, int obj2) { return true; } public static bool operator !=(StrangeInt obj1, int obj2) { return false; } } static void Main(string[] args) { StrangeInt a = new StrangeInt(); if(a==1 && a==2 && a==3) { Console.WriteLine("Hurraa"); } }
source share