Skip to content

Instantly share code, notes, and snippets.

@markrendle
Created January 30, 2011 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markrendle/802741 to your computer and use it in GitHub Desktop.
Save markrendle/802741 to your computer and use it in GitHub Desktop.
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