Quick generics related question/problem

So for the first time in my life im trying to implement a solution to a problem that i have using generics. What i devised was those classes.

public abstract class BaseUnitModifier <T> where T : BaseUnitModifierController { public T Controller; } 

/////////////////

public abstract class BaseAttackAlteration <T> : BaseUnitModifier <T> where T : BaseAttackAlterationController { //stuff } 

/////////////////

public class DefaultAttack : BaseAttackAlteration < DefaultAttackController> { //stuff } public class DefaultAttackController : BaseAttackAlterationController { //stuff } 

And now i want to have a list of BaseAttackAlterations (its subclasses objects to be more precise) so what i did is

protected List<BaseAttackAlteration<BaseAttackAlterationController>> AttackStrategies; 

But since its done in unity, it doesnt like the solution. Is there a way of doing the thing im trying to do that looks like this?

protected List<BaseAttackAlteration> AttackStrategies; 

by Illusive_S via /r/csharp

Leave a Reply