I've been struggling for quite some time now with the following problem. Consider the following C# code:
public interface Foo<TD>
{
List<TD> Bravo { get; set; }
List<double> Yey { get; set; }
}
public class IS : Foo<int>
{
}
public class DS : Foo<double>
{
}
I have another generic class, say DE<TS>
, where TS
is constrained to be either IS
or DS
. A snippet of this class would be as follows:
public class DE<TS> // : where TD must be IS or DS...
{
public void DoSomething(TS s)
{
// Some instruction that needs that need Foo<TD> properties to be visible...
}
}
Implementing such a class may be "simple" using Java through the usage of generic wildcards. For instance, the DE class could have a signature DE<TS extends Foo<?>>
.
Among the related searches, this answer would be perfect if I did not need Foo<TD>
properties.
How can I achieve my desired outcome in this situation?