Hello everyone,
I have a string array, but may have duplicate strings. Any built-in or smart way to remove the duplicate ones and generate a string array contains only unique ones?
For example, the input array is {"abc", "bcd", "abc"}, the unique output array is {"abc", "bcd"}.
thanks in advance,
George

Jan MontanoRank #1,295 · 1.3K reputationPosted Dec 22, 2008, 7:54 PM EST
string[] array = new string[]{"one","two","three","two","four","one","five"};
List
for (int i=0; i
if (!list.Contains(array[i])) list.Add(array[i]);
}
string[] newArray = list.ToArray();
George GeorgeRank #1,736 · 870 reputationPosted Dec 22, 2008, 8:46 PM EST
Thanks Jan!
I like your solution!
regards,
George