Tuesday, April 5, 2011

Get Distinct Value from Array

public static string[] RemoveDuplicates(string[] s)
{

HashSet set = new HashSet(s);
string[] result = new string[set.Count];
set.CopyTo(result);
return result;
}

When you use HashSet, you need to import System.Collections.Generic and add Reference (System.Core).


Thank you very much.

No comments:

Post a Comment

If this post is useful, pls comment here.