I have 3 classes: A, B and C
All these classes implement the IMyInterface interface.
I would like the interface to be defined as follows:
internal IMyInterface<E> where E: class { E returnData(); }
So that it can return data of type E. Type "E" will be a POCO object created using Entity Framework v4.
In a separate class I have:
public class MyClass() { IMyInterface<??> businessLogic; public setBusinessLogic(IMyInterface<E> myObject) where E : class { businessLogic = myObject; } }
I tried putting <object> instead of <??> , but it could not use my poco object type.
I tried my objects implement an empty IEntity interface, then using
IMyInterface<IEntity> businessLogic; ... businessLogic = new A<POCOObject>();
leads to:
Cannot implicitly convert type 'A<POCOObject>' to 'IMyInterface<IEntity>'. An explicit conversion exists (are you missing a cast?)
Any recommendations?
Edit: I tried declaring classes A, B, and C as:
internal class A : IBidManager<EntityObjectType>
and
internal class A<E> : IBidManager<E> where E : class
leads to the same error.
source share