Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save metametaclass/c0b900b2c42bb55a2691fcbb64ee8b19 to your computer and use it in GitHub Desktop.
Save metametaclass/c0b900b2c42bb55a2691fcbb64ee8b19 to your computer and use it in GitHub Desktop.
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);
}
}
}
@metametaclass
Copy link
Author

Do 2 String
Cons: String
Do 1 String
Do 2 Int32
Cons: Int32
Do 1 Int32
Do 2 Double
Cons: Double
Do 1 Double

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment