Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 903
greggorob64 Avatar asked May 23 '11 13:05

greggorob64


1 Answers

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, 
like image 179
Oded Avatar answered Sep 28 '22 01:09

Oded