我有以下C#代码:
public class A
{
public static A amethod()
{
return new C()
}
}
public class C : A
{
}
static void Main(string[] args)
{
dynamic obj1 = A.amethod()
}
Run Code Online (Sandbox Code Playgroud)
obj1运行应用程序后,为什么类型是C而不是A?
例如,我有这个C#方法:
public static int Count<T>(IEnumerable<T> sequence)
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么我必须写,Count<T>而不是Count当我不使用T方法内的类型?