【发布时间】:2011-04-05 16:02:19
【问题描述】:
class Student
{
public string ID { get; set; }
public string Name { get; set; }
}
Student[] students = new Student[10];
int j = 0;
for(int i=0; i < 100; i++)
{
if (some condition)
{
student[j].ID = anotherIDlist[i]; //some value from another list;
student[j].Name = anotherNamelist[i]; //some value from another list;
j++;
}
}
这里我不知道数组长度。需要它动态取决于总条件是否正确。有没有使用通用列表做同样的有效方法?如果有,该怎么做?
【问题讨论】:
标签: c# arrays generics generic-list