从数组中删除重复项的算法. 范例: 国家名称重复的数组,如 (印度",巴基斯坦",美国,德国",巴基斯坦",英格兰",爱尔兰",印度"). (可以开发Windows窗体来演示这一点).
Algorithm to remove duplicates from an array. Example : array having duplicate country names Like (‘India’,’Pakistan’,United states ofAmerica’,’Germany’,’Pakistan’,’England’,’Ireland’,’India’). (A windows form can be developed to demonstrate this)
推荐答案我认为这不是您的作业. 无论如何,我都不会直接给出代码,请在此处查看详细信息/选项 stackoverflow/questions/9673/remove-duplicates-from-array [ ^ ] I suppose this is not your homework. Any way I wont give direct code, check out the details/options here stackoverflow/questions/9673/remove-duplicates-from-array[^]
IEnumerable接口的不同扩展方法可用于此目的. Distinct extension method of IEnumerable Interface can be used for this purpose. string[] Countries = { "India", "Pakistan", "United States of America", "Germany", "Pakistan", "England", "Ireland", "India"}; var query = Countries.Distinct(); var distinctCountries = query.ToArray();
可以提供IEqualityComparer<T>参数来控制字符串的比较.
The IEqualityComparer<T> parameter can be supplied for controlling comparison of strings.