greggorob64
greggorob64

Reputation: 2557

Constraint syntax with generics, also deriving from a class

I'm having a heck of an issue with the following: I have a generic class, with a constraint, that derives from a non-generic interface:

public abstract class DrilldownBase<W> where W : class, IDrilldown

This code is not correct through, because it thinks IDrilldown is a constraint, when its NOT. What I want is for the class DrilldownBase to inherit from IDrilldown. What am I missing?

Thanks.

Upvotes: 5

Views: 1070

Answers (1)

Oded
Oded

Reputation: 499202

Don't make it part of the constraint then.

The constraint should come after the inheritance declaration:

public abstract class DrilldownBase<W> : IDrilldown where W : class, 

Upvotes: 7

Related Questions