DNC Magazine Issue 2 - September 2012
In our September
2012 Issue of 'DNC Magazine' we have inverviewed
Jon Skeet.
We requested Jon to give us three trivia questions for you to take a crack at.
You can Subscribe to the Magazine for FREE here
Jon's C# Trivia
Q1. What constructor call can you write such that this prints True (at least on the Microsoft .NET implementation)?
object x = new /* fill in code here */; object y = new /* fill in code here */; Console.WriteLine(x == y);
Q2. How can you make this code compile such that it calls three different method overloads?
void Foo() { EvilMethod<string>(); EvilMethod<int>(); EvilMethod<int?>(); }
Q3. With a local variable (so no changing the variable value cunningly), how can you make this code fail on the second line?
string text = x.ToString(); // No exception Type type = x.GetType(); // Bang!
Please leave your answers below! Don't be afraid if it's wrong :) and No posting on Stack Overflow ;-).