0

有没有办法像这样命名一系列对象:

for (i=0; i<numberOfObjectsDesired; i++;) {
    Object ("thisone"+i);
    thisone+i = new Object();
}

这样 thisone0, thisone1, thisone2, thisone3, ... 等都是 Objects 的唯一实例

4

1 回答 1

2

当然,它被称为数组

var thisone = new object[numberOfObjectsDesired];

for (i=0; i<numberOfObjectsDesired; i++;) {
    Object ("thisone"+i);
    thisone[i] = new Object();
}

请注意,您必须将您的实例称为thisone[0],thisone[1]等,而不是thisone0, thisone1, ...

于 2012-06-14T20:26:48.337 回答