Click here to Skip to main content
15,886,769 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to remove characters from string value Pin
Paladin200024-Jan-11 3:54
Paladin200024-Jan-11 3:54 
QuestionBuild and use user control (vs 2010) Pin
ladoota22-Jan-11 20:13
ladoota22-Jan-11 20:13 
AnswerRe: Build and use user control (vs 2010) Pin
Richard MacCutchan22-Jan-11 21:38
mveRichard MacCutchan22-Jan-11 21:38 
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 
First time when "A" is added to the output string, it is the first character in the array element. When it is added second time, it not "A" its " A" which gets added. You should be using trim to get rid of that additional characters.

Also, you can make use of LINQ to make your code compact. Here is something quick I came up with (not the most efficient way though):
String[] Arr = { "A, B, C", "B, A, C", "C, A", "B, C, A", "D, A, N, V", "N, W, B, A" };

            string uniqueCharacters = string.Empty;

            foreach (string str in Arr)
            {
                List<string> values = str.Split(',').Distinct().ToList();
                values.ForEach(x => uniqueCharacters = !uniqueCharacters.Contains(x.Trim()) ? uniqueCharacters + "," + x : uniqueCharacters);

            }

            uniqueCharacters = uniqueCharacters.Remove(0, 1);


Make sure to consider the size of array. If it is too huge, you may want to use StringBuilder instead of plain concatenation.
"Your code will never work, Luc's always will.", Richard MacCutchan[^]

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 
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 

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.