I have An array of integers {100,50,30,100,20,30,50,10,5}
Can any one help in this to find the Same No’s Count…?
I have An array of integers {100,50,30,100,20,30,50,10,5}
Can any one help in this to find the Same No’s Count…?
Hi,
What is expected result?
If it’s 3, the following will work.
arrInt.GroupBy(Function(i) i).Count(Function(g) g.Count>1)
Regards,
Thanks for your response @Yoichi but I have only 2 duplicates in my array how it was giving 3 as result.
i need the result as how many 100’s are same (i.e. That count)… 50’s are same (i.e. That count). 20’s are same (i.e. That count)…
Please try this
Arr.GroupBy(function(x) x).where(function(x) x.Count>1).ToDictionary(function(g) g.Key.ToString,function(g) g.Count.Tostring)
This would give you dictionary output with the value and the count…make sure to create a dictionary of string and string and initialize with New dictionary(of string,string)
Cheers
Hi,
Can you try the following sample?
dict = arrInt.GroupBy(Function(i) i).Where(Function(g) g.Count>1).ToDictionary(Function(g) g.Key,Function(g) g.Count)
Sample20230324-2aL.zip (2.6 KB)
Regards,
Thank you For your valuable time its working
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.