【发布时间】:2011-02-06 17:09:21
【问题描述】:
如何在下面的代码中编辑列表中的项目:
List<Class1> list = new List<Class1>();
int count = 0 , index = -1;
foreach (Class1 s in list)
{
if (s.Number == textBox6.Text)
index = count; // I found a match and I want to edit the item at this index
count++;
}
list.RemoveAt(index);
list.Insert(index, new Class1(...));
【问题讨论】:
-
你应该为你的文本框命名。
-
也许描述代码的意图会有所帮助。
标签: c# .net generic-list