Created
January 30, 2011 10:09
-
-
Save ThatRendle/802741 to your computer and use it in GitHub Desktop.
My solution (without looking) to http://msmvps.com/blogs/jon_skeet/archive/2010/11/02/evil-code-overload-resolution-workaround.aspx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace OverloadResolutionChallenge | |
{ | |
class Program : One | |
{ | |
static void Foo<T>(T? t = default(T?)) where T : struct | |
{ | |
Console.WriteLine("struct"); | |
} | |
static void Foo<T>(IClass<T> t = null) where T : class | |
{ | |
Console.WriteLine("class"); | |
} | |
interface IClass<T> where T : class | |
{ | |
} | |
static void Main(string[] args) | |
{ | |
Foo<int>(); | |
Foo<string>(); | |
Foo<int?>(); | |
} | |
} | |
class One | |
{ | |
protected static void Foo<T>() | |
{ | |
Console.WriteLine("nullable"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment