【发布时间】:2014-05-27 06:19:04
【问题描述】:
我想在表单加载时将标签放在一个数组中,但我不想一个一个地对它们进行编码,我想使用一个 for 循环,但我不知道这在 C# 中是如何工作的。
我的代码:
Dates[0] = this.labelrect0;
Dates[1] = this.labelrect1;
Dates[2] = this.labelrect2;
Dates[3] = this.labelrect3;
我想做什么:
for(int n = 0; int > array.Count; c++)
{
Dates[n] = this.labelrect+n; //how do i concatenate n to labelrect?
}
【问题讨论】:
-
一种非直接的方式可能是将标签放在
Label[] labelrect数组中并通过labelrect[n]寻址它们。然后Dates[n] = this.labelrect[n]循环。