Domnic Domnic - 2 months ago 14
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());