我有一个 List 和一个 ListItemCollection 并想检查是否有相同的元素。
首先,我用文本和值填充 ListItemCollection。(在 SQL 选择之后)
ListItemCollection tempListName = new ListItemCollection();
ListItem temp_ListItem;
if (reader.HasRows)
{
while (reader.Read())
{
temp_ListItem = new ListItem(reader[1].ToString(), reader[0].ToString());
tempListName.Add(temp_ListItem);
}
}
我有清单
List<string> tempList = new List<string>(ProfileArray);
有一些值,如 {"1","4","5","7"}
现在,我想检查一下 tempList 是否在 tempListName 中可能有一些具有相同值的元素,并从值中读取文本并将其写入新列表中。
注意:我使用的是 asp.net 2.0。