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

Advertisements

~ 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: