How do you remove repeated characters in a string

后端 未结 7 448
感情败类
感情败类 2020-12-09 11:44

I have a website which allows users to comment on photos. Of course, users leave comments like:

\'OMGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

7条回答
  •  臣服心动
    2020-12-09 12:30

    Distinct() will remove all duplicates, however it will not see "A" and "a" as the same, obviously.

    Console.WriteLine(new string("Asdfasdf".Distinct().ToArray()));
    

    Outputs "Asdfa"

提交回复
热议问题