I'm aware that C# doesn't have generic wildcards, and that a similar effect can be achieved by generic methods, but I need to use a wildcard in a field and can't work out if there is any way to encode it.
List<State<Thing>> list;
void AddToList<T>() where T : Thing {
list.Add(new State<T>());
}
Of course, this doesn't work because the object being added isn't of type State<Thing>
, it's of type State<T> where T : Thing
. Is it possible to adjust the most internal type of the list to be the Java equivalent of ? extends Thing
rather than just Thing
?
List<State<T>> where T : Thing
? – Santana