Display unique characters only in a text box

If I give input in a textbox like

AaBbcdCDEb

the output should be

ABCDE or abcde

only unique characters should be present, no duplicate characters.

How to do it?

-3


source to share


3 answers


Use the Distinct extention method on the character array and then recompile them to a string.



new string("AaBbcdCDEb".ToLower().Distinct().ToArray());

      

+4


source


string input = "AABBCCDD";
string output = string.empty; 
foreach(char c in input)
    if (!output.Contains(c))
        output += c;

      



+1


source


foreach char in textbox if textbox / newline contains char then return, else add on newline?

0


source







All Articles