I know it could be done in JavaScript
But is there any possible solution to print "Hurraa" on the condition given below in C# without multi-threading?
if (a==1 && a==2 && a==3) {
Console.WriteLine("Hurraa");
}
Answer
Sure, its the same concept as a few of the javascript answers. You have a side effect in a property getter.
private static int _a;
public static int a { get { return ++_a; } set { _a = value; } }
static void Main(string[] args)
{
a = 0;
if (a == 1 && a == 2 && a == 3)
{
Console.WriteLine("Hurraa");
}
Console.ReadLine();
}
No comments:
Post a Comment