标签:
原型:
private List<Dictionary<string, string>> lstData = new List<Dictionary<string, string>>();
集合添加数据,重复的自动去掉
for (int i = 0; i < listView.Items.Count; i++) { //获取list控件的集合 Dictionary<string, string> dicData = new Dictionary<string, string>(); dicData.Add(this.listView.Items[i].SubItems[2].Text, this.listView.Items[i].SubItems[3].Text); if (lstData.Exists(x => { foreach (var name in x.Keys) { if (name == this.listView.Items[i].SubItems[2].Text) { return true; } } return false;}) ) { continue; } lstData.Add(dicData); }
标签:
原文地址:http://www.cnblogs.com/llcdbk/p/4607653.html