Skip to content

Instantly share code, notes, and snippets.

@AntonC9018
Created September 20, 2022 09:46
Show Gist options
  • Save AntonC9018/453d818ad058cb7d4c9f673f72def2ea to your computer and use it in GitHub Desktop.
Save AntonC9018/453d818ad058cb7d4c9f673f72def2ea to your computer and use it in GitHub Desktop.
Overloading generics in C# proof of concept
public static class A
{
public static void a<T>(this T[] l, in T t) where T : struct
{
}
}
public static class B
{
public static void a<T>(this T[] l, T t) where T : class
{
}
}
public static class C
{
public static void Test()
{
int[] l = { 1, 2, 3 };
l.a(l[0]);
object[] k = { 1, 2, 3 };
k.a(k[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment