Is there a c# language construct that will allow me to add items to a readonly collection property in a constructor? I want to do something like this:
public cl
You can add a backing field to the "Children" property, then just populate the backing field during construction.
Like so
public class Node
{
private IList _Children;
public IList Children { get { return _Children; } }
public Node(IList children)
{
_Children = children;
}
}
Then you can do this
var node = new Node((new ObservableList()).Add(new Node()));