tags:

views:

392

answers:

3

If I give the input from Text Box like

AaBbcdCDEb

the output should be

ABCDE or abcde

only unique characters should be there, no repeated characters.

How do I do this?

+4  A: 

Use the Distinct extention method on the array of characters then recombine them into a string.

new string("AaBbcdCDEb".ToLower().Distinct().ToArray());
joegtp
can u send me code........pls i am beginner practicing
Masuma Aktar
He did, didn't he?
Shahin
This will only work IF he is with framework3, not 2.0...
Daok
Beautiful. I love LINQ.
Lee Richardson
A: 

foreach char in textbox, if textbox/new string contains char then return, else add to new string?

xoxo
Sir i want to give dynamic input at run time from TextBox.....if the the input is AABBCCDD and if i click one Button the result should be displayed in another TextBox.....Result should be only ABCD.......sir pls send me the entire code.
Masuma Aktar
FedEx, TNT, UPS what's you favourite?
Drejc
+1  A: 
string input = "AABBCCDD";
string output = string.empty; 
foreach(char c in input)
    if (!output.Contains(c))
        output += c;
Bob
Thank you sir its working fine......but its working only for either uppercase or lower case not both i mean if i give input "AAABBCCDDaabbccdd" the output is coming "ABCDabcd" but output should be either"ABCD" only or "abcd"only but not both.....pls send me sir.
Masuma Aktar
Do your own work or go into another field.
ctacke