Domnic Domnic - 21 days ago 7
C# Question

How to get distinct characters in c#

I have a code like

String code="AABBDDCCRRFF";


In this code I want to retrive only distinct characters

The Output should be like:

ANS: ABDCRF

Answer
        string code = "AABBDDCCRRFF";
        string answer = new String(code.Distinct().ToArray());
Comments