Click here to Skip to main content
15,888,590 members
Home / Discussions / C#
   

C#

 
AnswerRe: Build and use user control (vs 2010) Pin
RaviRanjanKr23-Jan-11 17:36
professionalRaviRanjanKr23-Jan-11 17:36 
QuestionRemoving duplicates / extracting unique vals from String array Pin
csrss22-Jan-11 1:25
csrss22-Jan-11 1:25 
AnswerRe: Removing duplicates / extracting unique vals from String array Pin
Luc Pattyn22-Jan-11 1:54
sitebuilderLuc Pattyn22-Jan-11 1:54 
GeneralRe: Removing duplicates / extracting unique vals from String array Pin
csrss22-Jan-11 2:07
csrss22-Jan-11 2:07 
AnswerRe: Removing duplicates / extracting unique vals from String array Pin
dan!sh 22-Jan-11 2:04
professional dan!sh 22-Jan-11 2:04 
GeneralRe: Removing duplicates / extracting unique vals from String array Pin
csrss22-Jan-11 2:09
csrss22-Jan-11 2:09 
AnswerRe: Removing duplicates / extracting unique vals from String array Pin
PIEBALDconsult22-Jan-11 3:30
mvePIEBALDconsult22-Jan-11 3:30 
AnswerRe: Removing duplicates / extracting unique vals from String array [modified] Pin
DaveyM6922-Jan-11 5:47
professionalDaveyM6922-Jan-11 5:47 
Combining the excellent answers you already have into a one liner using Linq (if available in the .NET version you are using)
C#
string[] vals = text.Split(',').Select(t => t.Trim()).Distinct().ToArray();


Edit: This will only ensure unique in each group separated by ','. The easiest way to get unique between all groups may be to combine all the string array elements into one string and perform this operation on the full string e.g.
C#
string[] vals = string.Join(",", arr) // join to make one string
    .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) // split to array
    .Select(t => t.Trim()) // trim each entry
    .Distinct() // ensure unique
    .ToArray(); // back to array


Not sure how efficient this is, but it works!
Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



modified on Saturday, January 22, 2011 12:27 PM

GeneralRe: Removing duplicates / extracting unique vals from String array Pin
Mirko198024-Jan-11 22:11
Mirko198024-Jan-11 22:11 
QuestionPlease Check Pin
M Riaz Bashir21-Jan-11 23:25
M Riaz Bashir21-Jan-11 23:25 
AnswerRe: Please Check Pin
OriginalGriff21-Jan-11 23:42
mveOriginalGriff21-Jan-11 23:42 
GeneralRe: Please Check Pin
M Riaz Bashir21-Jan-11 23:48
M Riaz Bashir21-Jan-11 23:48 
GeneralRe: Please Check Pin
Henry Minute22-Jan-11 4:00
Henry Minute22-Jan-11 4:00 
AnswerRe: Please Check Pin
_Erik_24-Jan-11 3:43
_Erik_24-Jan-11 3:43 
Questioni want to solve this Pin
Nabawoka21-Jan-11 22:21
Nabawoka21-Jan-11 22:21 
AnswerRe: i want to solve this Pin
Richard MacCutchan21-Jan-11 22:35
mveRichard MacCutchan21-Jan-11 22:35 
GeneralRe: i want to solve this Pin
Nabawoka21-Jan-11 22:39
Nabawoka21-Jan-11 22:39 
AnswerRe: i want to solve this Pin
Nabawoka21-Jan-11 22:55
Nabawoka21-Jan-11 22:55 
GeneralRe: i want to solve this Pin
Estys21-Jan-11 23:00
Estys21-Jan-11 23:00 
GeneralRe: i want to solve this Pin
Nabawoka22-Jan-11 0:02
Nabawoka22-Jan-11 0:02 
AnswerRe: i want to solve this Pin
Estys22-Jan-11 0:30
Estys22-Jan-11 0:30 
GeneralRe: i want to solve this Pin
OriginalGriff22-Jan-11 0:41
mveOriginalGriff22-Jan-11 0:41 
GeneralRe: i want to solve this Pin
Dave Kreskowiak22-Jan-11 9:03
mveDave Kreskowiak22-Jan-11 9:03 
GeneralRe: i want to solve this Pin
Estys22-Jan-11 11:26
Estys22-Jan-11 11:26 
AnswerRe: i want to solve this Pin
Estys21-Jan-11 23:00
Estys21-Jan-11 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.