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

编程入门 行业动态 更新时间:2024-10-26 13:28:26
本文介绍了从数组中删除重复项的算法.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

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

本文发布于:2023-11-30 11:08:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649757.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:算法   组中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!