I have a collection of data models that have associations with other models, and the data schema is often circular in nature. I want to create C# classes to represent this data objects, but it'll result in circular references.
Here is a simple example
class ClassA {
public ClassB parent;
}
class ClassB {
public ClassA child;
}
When these two classes are instantiated with a circular reference to each other. Will C# leak memory? How will the garbage collector know to release these?
I remember in Java there was a feature that allowed you to define a class member as having a weak
reference. Does C# have something like that?