默认情况下,引用类型数组被初始化为所有引用为空。
是否有任何语法技巧可以用新的默认对象来初始化它们?
例如
public class Child
{
}
public class Parent
{
private Child[] _children = new Child[10];
public Parent()
{
//any way to negate the need for this?
for (int n = 0; n < _children.Length; n++)
_children[n] = new Child();
}
}