5

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.

greggorob64
  • 2,487
  • 2
  • 27
  • 55

1 Answers1

7

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, 
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • Thanks. That syntax seems strange to me, the fact that there is no delimiter between IDrilldown and where is different. I'll mark you as answer when the min wait period is up. – greggorob64 May 23 '11 at 13:18
  • 1
    @greggorob64 good style is to put the where clause on the next line – Yaur May 23 '11 at 14:07
  • Noted, thanks. My native language is actually VC++.net. I always translate my code questions before I post on SO for more exposure. Long story short, in VC++, you have to put the generic constraints BEFORE the function. – greggorob64 May 23 '11 at 15:14
  • @greggorob64 - I know your pain... I happens to me whenever I transition to a language different from my current main. Glad I could help. – Oded May 23 '11 at 15:56