从删除列表中的重复字符串(.NET 2.0!) [英] Removing duplicate string from List (.NET 2.0!)

查看:101
本文介绍了从删除列表中的重复字符串(.NET 2.0!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,找到最有效的方式,从一个字符串列表(列表)删除重复。

I'm having issues finding the most efficient way to remove duplicates from a list of strings (List).

我目前的实施是一个双foreach循环检查每个对象的实例数仅为1,否则除去第二。

My current implementation is a dual foreach loop checking the instance count of each object being only 1, otherwise removing the second.

我知道还有很多其他的问题在那里,但他们所有的最好的解决方案需要上述.NET 2.0,这是当前构建环境,我的工作(通用汽车和克莱斯勒的变化非常耐...: ))

I know there are MANY other questions out there, but they all the best solutions require above .net 2.0, which is the current build environment I'm working in. (GM and Chrysler are very resistant to changes ... :) )

这不容许任何LINQ,或HashSets限制了可能的结果。

This limits the possible results by not allowing any LINQ, or HashSets.

在code我使用的是的Visual C ++,但C#的解决方案,将工作也很不错。

The code I'm using is Visual C++, but a C# solution will work just fine as well.

谢谢!

推荐答案

这可能不是你要找的,但如果你有过这样的控制,最有效的方法是不添加他们的第一个地方...

This probably isn't what you're looking for, but if you have control over this, the most efficient way would be to not add them in the first place...

你有没有过这样的控制?如果是这样,所有你需要做的是 myList.Contains(currentItem)通话,然后添加的项目,你就设置

Do you have control over this? If so, all you'd need to do is a myList.Contains(currentItem) call before you add the item and you're set

这篇关于从删除列表中的重复字符串(.NET 2.0!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆