Hi, I have an Array which is {apple, orange, mango, banana, orange, apple}. I want to find the duplicate items and the count of occurrence of that particular item from that array. can any body please help me to do this. Thanks
@kumarD
following on our discussion you will find some explanations on the implementation below:
build datatable - setting the datatable structure for the statistic report
Linq statement - retrieving the occurence count for the different array items:
(From x In arrValues
Group x By k=x Into grp=Group
Select dtReport.Rows.Add({k,grp.Count})).CopyToDataTable
(From x In arrValues - looping over all items from the array
Group x By k=x Into grp=Group - forming groups of all items with the same value
Select dtReport.Rows.Add({k,grp.Count})).CopyToDataTable - adding datarow to the reportdatatable with the item value and the occurence. occurence is retrieved from the count of the group members (grp.count)
refer also to here:
1 Like
Hi @ppr thank you for explaining it in a simple way. Is there any other way to do it without using “LinQ” or “VB/.Net code” ?
Thanks