110,538
社区成员
发帖
与我相关
我的任务
分享
class C0
{
public static string s = "0";
public static string gets()
{
return s;
}
}
class C1 : C0
{
public new static string s = "1";
}
class C2 : C0
{
public new static string s = "2";
}
C1.gets(); // 得到1
C2.gets(); // 得到2
class C0
{
public static string s = "0";
public static string gets<T>() where T:C0
{
return typeof(T).GetField("s").GetValue(null).Tostring();
}
}
class C1 : C0
{
public new static string s = "1";
}
class C2 : C0
{
public new static string s = "2";
}
C1.gets<C1>(); // 得到1
C2.gets<C2>(); // 得到2