Hi,

I have a collection of (String, Integer). I have taken it into a String() Array and then added to a List(Of String()). I then need to find the duplicates in this list and if found, then add up the corresponding integers. How do I do this? Am I using the right Collection? If not which one would be the best?

Thanks

Can you please clarify what you mean by "corresponding integers"? As a guess as to your intentions, you could create a dictionary object where the key (string) is a given string and the value is the number of times that string occurs. Loop over the strings, adding the new ones with a value of 1 and incrementing that value by 1 if the string already exists in the dictionary. Iterating over the keys when completed will give you the unique strings. The final values will give you the number of occurrences of each string.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.