Would it be possible to do something like the following in c#? Basically TParent and TChildren should be types of the class A but not necessairly have the same types that were passed in. I know this may sound confusing but I want to strongly type the children and parents of a particular object, but at the same time they must be of the same type. Because TParent inherits from A this would imply that it requires type parameters that inherit from A but using potentially different types.
public class A<TParent, TChildren>
where TParent : A
where TControls : A
{
TParent Parent;
List<TChildren> Children;
}
or more easily seen here:
public class A<TParent, TChildren>
where TParent : A<?, ?>
where TChildren : A<?, ?>
{
TParent Parent;
List<TChildren> Children;
}
I hope this isn't too confusing. Is this at all possible?
Thanks :)