C / C++ / C#

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
photo of David Bolton

David's C / C++ / C# Blog

By David Bolton, About.com Guide to C / C++ / C#

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

August 21, 2008 at 4:13 am
(1) ria says:

It will compile and output as i=9.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore C / C++ / C#

About.com Special Features

C / C++ / C#

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.