Remove Duplicates in one string

Hello,

I want to remove duplicates in one string anyone can help for that.

INPUT
Hello Good morning |this is XYZ im From ABC |this is XYZ im From ABC | Today My birthday

OUTPUT
Hello Good morning |this is XYZ im From ABC |Today My birthday

Thanks in advance.

Hi @Shriharsha_H_N

Try this

youstringvariable.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)

Thanks
Ashwin.S

Hi @Shriharsha_H_N,

The below line of code will resolve this, tested and working fine with the input you have mentioned here.

String.Join(" ", strInput.Split(" "c).Distinct())
6 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.