卸下阵列复制 [英] Remove duplicates from array
本文介绍了卸下阵列复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直与该会从函数调用返回的的String []
数组在C#。我想知道去除此阵副本将是最好的方法是什么?我可能转换为泛型集合,但我不知道是否有更好的方式来做到这一点,可能通过使用一个临时数组吗?
I have been working with a string[]
array in C# that gets returned from a function call. I was wondering what the best way to remove duplicates from this array would be? I could possibly cast to a Generic collection, but I was wondering if there was a better way to do it, possibly by using a temp array?
推荐答案
您可以使用可能LINQ查询做到这一点:
You could possibly use a LINQ query to do this:
int[] s = { 1, 2, 3, 3, 4};
int[] q = s.Distinct().ToArray();
这篇关于卸下阵列复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文