I'm trying to write a generic function like the example of the image below. The idea is to have a method that will receive a generic type that must inherit an abstract class that has a generic configuration which has another abstract class.
public class MainCode
{
public MainCode()
{
Execute<DefaultOptions>();
}
public void Execute<T>() where T : BaseClassOptions<BaseClassConfiguration> { }
}
public class DefaultOptions : BaseClassOptions<DefaultConfiguration> { }
public abstract class BaseClassOptions<T> where T : BaseClassConfiguration
{
public T Config { get; set; }
}
public class DefaultConfiguration : BaseClassConfiguration { }
public abstract class BaseClassConfiguration
{
public string Host { get; set; }
}
But I got the following error:
Could you please help me?