我试图完成以下场景,通用TestClassWrapper将能够访问它所构成的类的静态属性(它们都将从TestClass派生).就像是:
public class TestClass
{
public static int x = 5;
}
public class TestClassWrapper<T> where T : TestClass
{
public int test()
{
return T.x;
}
}
Run Code Online (Sandbox Code Playgroud)
给出错误: 'T' is a 'type parameter', which is not valid in the given context.
有什么建议?
c# ×1