My scenario is : The bot needs to read all the letters in a word and return the number of times each letter appears in the word. e.g., If the word is Alankrita singh. The output should be A - 3, L - 1, N - 2, K - 1, R -1, I - 2, T - 1, S - 1, G - 1, H - 1. The code should be dynamic. It should be able to perform this operation on any word. Please suggest how can i do this ?
Can you explain me the function that you have use. How it is working in this case?
yourString.Distinct() returns list of non-duplicated items. in this case it’s {"A","B","C","D"}
Next, ToDictionary method returns dictionary which has the following key and value.
Key: Function(c) c returns each item of the above list, like "A","B","C"....
Value: yourString.Count(Function(s) s=c) returns count of characters which match each item and characters of yourString variable, like Count "A" in "ABCDABCA" , Count "B" in "ABCDABCA" …