0

I have a class declaration that looks like this:

public class BlueFinApiClient : IBlueFinApiClient

I am trying to turn this into a generic class and I have changed this declaration to:

public class BlueFinApiClient<T> : IBlueFinApiClient<T> where T : 
SREDApiRequest, BlueFinApiRequest , new()

But I cannot seem to get past this error:

The class type constraint 'SPS.CardDecryption.Engine.KSNDecryption.BlueFin.BlueFinApiRequest' must come before any other constraints

I am just failing to see what am I doing wrong in the declaration.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
Waddaulookingat
  • 337
  • 3
  • 16
  • You can't. Create two overloads or extract an interface. – CodeCaster Apr 18 '18 at 15:08
  • Type constraints are ANDed. So in your case, you're saying `T` must be of type `SREDApiRequest` (or subtype) AND of type `BlueFinApiRequest` (or subtype) (AND have a parameterless constructor). So at best, `SREDApiRequest` and `BlueFinApiRequest` are in some kind of subtype/supertype relation, which would make one of them superficial, just use the most specialized one, or at worst, they are two completely separate types, so you will never ever have a `T` that can be "both". – Corak Apr 18 '18 at 15:16

0 Answers0