我想在c#中创建一个抽象类,它从不同的接口“继承”,但是将具体的实现留给了子类.然而,编译器抱怨说,该类没有实现接口中指定的方法.我已经习惯了
Java总是有用的,所以我不确定它应该如何在c#中工作.无论如何,这是我的代码:
public abstract class MyClass : IDisposable,IPartImportsSatisfiedNotification { private string name; public MyClass(string name) { this.name = name; } }
解决方法
添加抽象方法:
public interface IPartImportsSatisfiedNotification { void SomeMethod(); } public abstract class MyClass : IDisposable,IPartImportsSatisfiedNotification { private string name; public MyClass(string name) { this.name = name; } public abstract void SomeMethod(); public abstract void Dispose(); } public class SubClass : MyClass { public SubClass(string someString) : base(someString) { } public override void SomeMethod() { throw new NotImplementedException(); } public override void Dispose() { throw new NotImplementedException(); } }