I've got an abstract
class which has a type constraint. But i also want to make the abstract
class implement an interface.
E.g:
public abstract class PostEvent<TPost> : IDomainEvent, where TPost : Post, new()
Which doesn't compile.
I don't want this:
public abstract class PostEvent<TPost> where TPost : Post, IDomainEvent, new()
Because that means TPost : IDomainEvent
I want PostEvent : IDomainEvent
What's the syntax?
Try this:
public abstract class PostEvent<TPost> : IDomainEvent where TPost : Post, new()
You don't want a comma between the interface list and the generic constraints.