Quiz Sharp #0

This is my first quiz, and is the result of a beatiful and long chat with my good friend Adrian Florea. Here the Italian version on his blog.

Look at this snippet:

struct Foo
{
	public static implicit operator bool(Foo value)
	{
		return value != null;
	}
}

static void Main(string[] args)
{
	if (new Foo())
	{
		Console.WriteLine("Hello word!");
	}
}

What will you get? And, first of all, why?

a) nothing

b) “Hello word!”

c) a compiler error

d) a runtime error

~ by Matteo on March 9, 2007.

One Response to “Quiz Sharp #0”

  1. Nice. We’ve discussed it at work and WE WANT MORE

Leave a Reply