Created
January 2, 2023 22:57
-
-
Save metametaclass/c0b900b2c42bb55a2691fcbb64ee8b19 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; | |
namespace test { | |
static class Test<T> { | |
static Test(){ | |
System.Console.WriteLine("Cons: {0}", typeof(T).Name); | |
} | |
public static void Do(T t) { | |
System.Console.WriteLine("Do 1 {0}", t.GetType().Name); | |
} | |
} | |
class Program { | |
static void Do<T>(T t) { | |
System.Console.WriteLine("Do 2 {0}", t.GetType().Name); | |
Test<T>.Do(t); | |
} | |
static void Caller(object obj){ | |
dynamic tmp = obj; | |
Do(tmp); | |
} | |
static void Main(string[] args) { | |
Caller("1"); | |
Caller(2); | |
Caller(3.0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do 2 String
Cons: String
Do 1 String
Do 2 Int32
Cons: Int32
Do 1 Int32
Do 2 Double
Cons: Double
Do 1 Double