Using C#
Interface A,
Interface B,
Class AA:A
{
public AA(A a)
{
//...
}
}
Class BB:B
{
public BB(B b)
{
//...
}
}
are the code works fine and not cause the circular reference problem?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why not? Syntax aside, self-similar structures appear all over computer science. Consider a binary tree: each node has a reference to two other trees (represented by their root nodes.) A typical way to make such a tree is a type that is constructed with not one, but two references to other instances of the type.
More generally, cycles in the type system are not the same as cycles in the object graph. Usually the first is by design, but the second has a way of turning into bugs..