Eric Chavez Eric Chavez - 2 months ago 24
C# Question

Assistant Using C# Generics

I have an interface which I use to map Entities Objects to Domain Objects

public interface IDataEntity<in T1, out T2> where T1 : new() where T2 : new()
T2 Map(T1 obj);

To implement

public class MyEntityObj : IDataEntity<MyEntityObj, MyDomainObj>
public MyDomainObj Map(MyEntityObj obj){
// mapping here
return new MyDomainObj();

How could I write the interface to allow me to write the implementation like this

public class MyEntity : IDataEntity<MyDomainObj>{



You can't. You will have to write out the full generic argument list.