A Silly C# Programming Puzzle!
Wednesday August 20, 2008
August is regarded as the silly season in the UK so here is a silly programming puzzle. What does this short bit of C# code do? Will it compile and/or run? Can you debug it?
# define i
using System;
using System.Text;
namespace ex11
{
class Program
{
static void Main(string[] args)
{
int i = 8;
# line hidden
++i;
# line 5
# pragma disable
# warning reverse execution is noitucexe
# line 4
# line 12
System.Console.WriteLine("i = {0}", i) ;
}
}
}
Answer tomorrow!


Comments
It will compile and output as i=9.