I'd like to create an abstract class in c#, that "inherits" from different interfaces, but leaves the concrete implementation to the subclass. The compiler however complains, that the class doesnt implement the methods specified in the interfaces. I'm used to Java where this always worked, so I'm not sure how it is supposed to work in c#. Anyway, this is my code:
public abstract class MyClass : IDisposable, IPartImportsSatisfiedNotification
{
private string name;
public MyClass(string name)
{
this.name = name;
}
}
Add abstract methods:
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();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With