Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个使用通用对象的类。泛型对象需要实现 IDisposable 接口。类还需要实现 IDisposable。
public class MyGenericClass<T> where T : IDisposable
现在在这个通用对象中实现了接口,但类没有。两者都有可能实现接口吗?如果是的话如何。
public class MyGenericClass<T> : IDisposable where T : IDisposable { public void Dispose() { throw new NotImplementedException(); } }
是的,有可能:
公共类 MyGenericClass: IDisposable where T : IDisposable