我怎样才能在.NET数组的独特价值? [英] How can I get the unique values of an array in .net?

查看:112
本文介绍了我怎样才能在.NET数组的独特价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有此数组: MYARRAY(0)=AAA MYARRAY(1)=BBB MYARRAY(2)=AAA

Say I've got this array: MyArray(0)="aaa" MyArray(1)="bbb" MyArray(2)="aaa"

有一个.NET函数,它可以给我的唯一值?我想这样的事情作为函数的输出: OutputArray(0)=AAA OutputArray(1)=BBB

Is there a .net function which can give me the unique values? I would like something like this as an output of the function: OutputArray(0)="aaa" OutputArray(1)="bbb"

推荐答案

假设你有净3.5 / LINQ:

Assuming you have .Net 3.5/LINQ:

string[] OutputArray = MyArray.Distinct().ToArray();

这篇关于我怎样才能在.NET数组的独特价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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