我有一些看起来像这样的代码:
class A<T>
where T : // what should I say here to make this work?
{
void foo()
{
int x = 0;
T y = (T)x; // this is a compile error without proper type restrictions
}
}
Run Code Online (Sandbox Code Playgroud)
目的是使用A类型,如double,float,int.