Friday C# Quiz: Know Your Closures
Although I've vowed not to post about closures anymore, I can't help but post one more quiz. I know Friday is mostly over for many of my readers, but there are still a few time zones left.
Without downloading Microsoft Visual C# 2008 Express Edition and compiling the following C# source file, answer the following question:
Q: Will the following program
public delegate int IntToInt(int i); public class Foo { public static IntToInt fib = n => n == 0 ? 0 : n == 1 ? 1 : fib(n - 1) + fib(n - 2); public static void Main() { System.Console.WriteLine(fib(6)); } }
compile? Run? If so, what will it print out?