I'm using something like these two classes:
class Binder1
{
public void Add(Binder2 toAdd)
{
toAdd.Add(this);
this.Add(toAdd);
}
}
class Binder2
{
void Add(Binder1 toAdd)
{
toAdd.Add(this);
this.Add(toAdd);
}
}
Instead of using a common parent class as the Add parameter I'd like to make use of generics, because it will be more convenient in the rest of the class functionality.
class Binder
{
public void Add(T toAdd)
{
toAdd.Add(this);
this.Add(toAdd);
}
}
class Binder1 : Binder
class Binder2 : Binder
but I don't know if that's possible. I'd very much appreciate help with design.
To me it seemed that single generic ID is not enough and that I can't go without
class Binder
and of course to specify the the base to make Add() callable
where T1: Binder
where T2: Binder
but I'm hitting on T1 vs Binder
I just probably make it too complicated and there is a much simpler way I don't see.
Is there?
Thanks very much for any suggestions.
Replies
Know the answer? Post it — somebody with the same question will find it here.