110,534
社区成员
发帖
与我相关
我的任务
分享
interface IMy<T>
{
T f();
}
class s<T> : IMy<T>
{
public T f() { return new T(); }
}
interface IMy<T>
{
T f();
}
class S<T> : IMy<T> where T : new()
{
public T f() { return new T(); }
}
要这样才对 不要写要接口上
interface IMy<T> where T : new()
{
T f();
}
class s<T> : IMy<T>
{
public T f() { return new T(); }
}
现在的编译错误是:
error CS0310: 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'ConsoleApplication1.Program.IMy<T>'
我现在还需要怎么改呢?