📅  最后修改于: 2022-03-11 14:49:02.334000             🧑  作者: Mango
T[] InitializeArray(int length) where T : new() {
T[] array = new T[length];
for (int i = 0; i < length; ++i) {
array[i] = new T();
}
return array;
}
// Usage:
MyObjects[] my_objects = InitializeArray(10);