0

I think I'd be easier to just write down my pseudo-class declaration.

Basically, I want something like

public class DatabaseControlsDAL<T> : T, IDatabaseControlsDAL where T : IBaseDAL
{
   public int myMethod()
   {
      return somePublicPropertyInTheIBaseDALInterface;
   }
}

But it won't work :(

Any help welcome !

Literal
  • 757
  • 6
  • 16

1 Answers1

0

Generics aren't a run-time feature, thus giving a generic argument won't be a run-time issue.

In the other hand, how would a class inherit what will be only known at run-time? Think C# is a strongly-typed language.

If B inherits A, but A is "unknown", then, until run-time, B won't be of type A. This defeats both the point of inheritance and polymorphism.

Conclusion: if you don't provide a background in order to let us define a better solution (well, an existing solution!), you'll get this answer: you can't achieve what you're looking for in C#.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206