How to get distinct characters?

前端 未结 9 1940
南旧
南旧 2020-12-10 10:21

I have a code like

string code = \"AABBDDCCRRFF\";

In this code, I want to retrieve only distinct characters

The Output should be l

9条回答
  •  北海茫月
    2020-12-10 11:09

    Just for the hell of it - using a StringBuilder

     string code = "AABBDDCCRRFF";
     StringBuilder sb = new StringBuilder();
     code.Distinct().ToList().ForEach(c => sb.Append(c));
     MessageBox.Show(sb.ToString());
    

提交回复
热议问题