【发布时间】:2013-12-17 15:12:19
【问题描述】:
BindingList 是否有任何解决方案来删除重复元素?我试过了:
BindingList<Account> accounts = new BindingList<Account>();
accounts.add(new Account("username", "password"));
accounts.add(new Account("username", "password"));
accounts = accounts.Distinct();
上述方法不起作用,因为 Distinct 返回的是 System.Collections.Generic.IEnumerable<T> 而不是 BindingList<T>
【问题讨论】:
-
你为什么不首先确保它们是唯一的?
-
@DanielA.White 帐户是从文本文件加载的,用户可能会输入重复的条目。先检查有什么好处吗?
-
您可以将它们加载到字典/哈希集中。
-
它们需要在一个 BindingList 中。 BindingList 是 DataGridView 的 DataSource。
标签: c# distinct ienumerable enumerable bindinglist