I have the following scenario:
public abstract class AAA<T> where T : BBB<T>
{
}
public abstract class BBB<T> : AAA<T> where T : BBB<T>
{
public void SomeMethod() { }
}
public class CCC : BBB<CCC>
{
}
And they are in turn used with the following.
public class YYY
{
public void Bar(BBB bbb, int value)
{
bbb.SomeMethod();
}
}
public class ZZZ : YYY
{
public void Foo()
{
CCC instance = new CCC();
Bar(instance, 0);
}
}
How do I structure the declaration of YYY.Bar() for parameter bbb so that it can accept an argument of type CCC? Class ZZZ knows about type CCC, but class YYY only has knowledge of AAA and BBB. This is common practice in other languages, e.g. Java, but I can't seem to make it work in C#.