Count of character duplicates in a string

Hi,

Example. String is “abcdab”. So here a and b are duplicates and has occurred twice. C and d are present only once. So I need to display like a=2, b=2, c=1, d=1. How to do this?

Thanks in advance.

Hi @Archana_N_L

Check this link : How to find the count of each element in an array that is duplicated and print that value in output? - #2 by Dominic

Regards,

Nived N

Happy Automation

Hi,

Hope the following helps you.

dict = "abcdab".GroupBy(Function(c) c).ToDictionary(Function(g) g.Key,Function(g) g.Count)

Note: dict is Dictionary<Char, Int32> type.

img20210310-1

3 Likes