How do you remove repeated characters in a string

后端 未结 7 447
感情败类
感情败类 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:21

    var nonRepeatedChars = myString.ToCharArray().Distinct().Where(c => !char.IsWhiteSpace(c) || !myString.Contains(c)).ToString();
    

提交回复
热议问题