Last active
March 1, 2021 10:21
-
-
Save kyubuns/1cf0305538ae582d7d2484d0605534cb to your computer and use it in GitHub Desktop.
This file contains 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; | |
public sealed class Dummy<T> { private Dummy() {} } | |
public interface IInterfaceA { } | |
public interface IInterfaceB { } | |
public class Hoge : IInterfaceA { } | |
public class Sandbox | |
{ | |
public static void Call<T>(T item, Dummy<IInterfaceA> dummy = default) where T : IInterfaceA => Console.WriteLine($"{item} is A"); | |
public static void Call<T>(T item, Dummy<IInterfaceB> dummy = default) where T : IInterfaceB => Console.WriteLine($"{item} is B"); | |
} | |
Sandbox.Call(new Hoge()); // Hoge is A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment