Код: Выделить всё
public class Layer
{
public string Name { get; set; }
private IEnumerable children;
public IEnumerable Children
{
get { return this.children.Where ( c => c.Name != null ).Select ( c => c ); }
set { this.children = value; }
}
public Layer ( )
{
this.children = new List ( ); // Fine
Layer layer = new Layer ( );
layer.children = new List ( ); // Isn't .children private from the outside?
}
}
Код: Выделить всё
Layer layer = new Layer ( );
layer.children = new List ( );
Я знаю причину использования:< /p>
Код: Выделить всё
this.children = ...
По какой причине это разрешено?
Подробнее здесь: https://stackoverflow.com/questions/573 ... -class-its