mercredi 27 mai 2020

How to find out the generic type passed to the parent

Tell me please how you can determine the type that was passed to the parameter generics during inheritance

public abstract class BaseEntity 
{
}

public class DogEntity : BaseEntity
{
}

public interface IAnimal
{
}

public abstract class Animal<TEntity> : IAnimal
    where TEntity : BaseEntity
{
}

public class Dog : Animal<DogEntity>
{
}

I have only Dog entity type, I need to get DogEntity

Type type = typeof(Dog);

I would be grateful for any help or hint





Aucun commentaire:

Enregistrer un commentaire