Click here to Skip to main content
15,885,944 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Removing duplicates / extracting unique vals from String array Pin
Mirko198024-Jan-11 22:11
Mirko198024-Jan-11 22:11 
Talking about efficiency, I read somewere on MSDN that, for generating a list of unique elements, the more efficient way is to use an HashSet (as PIEBALDconsult already said) instead of the Distinct extension method.
Something like this:

var query = string.Join(",", arr) // join to make one string
    .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) // split to array
    .Select(t => t.Trim()); // trim each entry

var set = new Hashset<string>

foreach (string item in query)
    set.Add(item); // add items to the hash set, this ensure unique

string[] vals = set.ToArray(); // back to array

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 
Questionhow to run a sever when the IIS runs? Pin
xaq69388826521-Jan-11 21:55
xaq69388826521-Jan-11 21:55 

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.