Click here to Skip to main content
15,885,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do i count value example

column Name and value.

ABCD
1
2
1
1
2
2
5
5
5
3
3
4
4

count 1 = 3
count 2 = 3

please somebody help.
Posted
Comments
Abhinav S 20-Jun-15 5:12am    
What have you tried so far?

1 solution

With Looping


1. Loop through the values.
2. Take a dictionary or key value pair representation.
3. Check if the value is already present in the dictionary by comparing it with the key.
4. If not present, then add the value (1/2/3) as a Key and count as the Value.
4. Increment count inside the loop.

LINQ


Use distinct count, like it is described here - C# LINQ counting elements with DISTINCT[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900