我有 foreach 循环到 listView 控件,我想为每个 listView 内容创建对象,所以我想通过 foreach 循环逐步更改对象的名称
foreach (var item in listViewStates.Items)
{
State s = new State
{
ID = MaxStateID,
Name = listViewStates.Items[0].Text,
WorkflowID = MaxWFID,
DueDate = Convert.ToInt32(listViewStates.SelectedItems[0].SubItems[1].Text),
Priority = Convert.ToInt32(listViewStates.SelectedItems[0].SubItems[2].Text),
RoleID = Convert.ToInt32(listViewStates.SelectedItems[0].SubItems[3].Text),
Status =Convert.ToInt32(listViewStates.SelectedItems[0].SubItems[4].Text)
};
i++;
}
变量是来自状态类的 s