我想使用方法重载来根据不同的泛型类型获得不同的结果.这是行不通的.我的代码清楚地表明了
static class Helper { public static bool Can(int i) { return true; } public static bool Can(Object o) { return false; } } class My<T> { public static bool can = Helper.Can(default(T)); } Console.WriteLine(Helper.Can(default(int)));//True,it is OK Console.WriteLine(My<int>.can);//false?? why the overload doesn't work Console.WriteLine(My<Object>.can);//false
为什么我的< int>调用Helper.Can(Object o)而不是Helper.Can(int i)?