最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

从数组中删除重复项的算法.

SEO心得admin34浏览0评论
本文介绍了从数组中删除重复项的算法.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

从数组中删除重复项的算法. 范例: 国家名称重复的数组,如 (印度",巴基斯坦",美国,德国",巴基斯坦",英格兰",爱尔兰",印度"). (可以开发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.

发布评论

评论列表(0)

  1. 暂无评论