How to remove duplicate values within a string variable

Hi All, I have a string variable , with multiple lines (each value within a separate line). I got this variable value by appending multiple values within a for loop. In the screenshot below you can see that certain values are repeated eg. “Director Data Quality”. What method can I use to keep only the unique values ?

snip2

@Ashish_Mehra

Try this.

           yourString.Split(Environment.NewLine.TocharArray).Distinct().Toarray()
1 Like

@lakshman Thanks a lot worked perfectly, could you also suggest on how I can now write this value to a particular cell within a data table ?

1 Like

@Ashish_Mehra

You want to write single value or whole Array into String.

So I wrote the whole array with distinct values into a string by using Strin.join(vbLF,arrayvariable) , now I have all the values I needed separated by line breaks, now I want to write this particular variable value into a cell in a data table I have built

@Ashish_Mehra

If you want to write into particular cell then use Write Cell Activity and pass that String to write into Excel file.

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