Well, you are going to have to cycle through all of the items, and
increment the value in the dictionary one at a time as you come across the
MainItem/SubItem combinations. As you cycle through every item (when
generating the count), if the key exists, then get the value, increment by
one, and then set the value back.
If the key doesn't exist, insert one for that key into the dictionary.
- Nick
"ArunDhaJ" <ar******@gmail.comwrote in message
news:be**********************************@k30g2000 hse.googlegroups.com...
Thanks Nicholas, I'm using C# 2.0.
After storing the key and value how can we query the dictionary to get
the total counts for individual Items. From the example in previous
posts, I need to get the total count of MainItem1 as 25, MainItem2 as
15 and MainItem3 as 19.
Thanks in advance
-ArunDhaJ
On Jun 4, 10:07 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
ArunDhaJ,
You could always create a structure with two fields, MainItem and
SubItem, then use that as a key in a dictionary, where the value is an
int.
Then, you can just add to the value in the dictionary as you come across
your fields.
Of course, if you are using LINQ, you could easily query your collection
and group on MainItem and SubItem and select the count for each group.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"ArunDhaJ" <arund...@gmail.comwrote in message
news:37**********************************@k30g2000 hse.googlegroups.com...
Hi
I need to manage count as follows:
MainItem1 SubItem1 - 10
MainItem1 SubItem2 - 5
MainItem1 SubItem3 - 10
MainItem2 SubItem1 - 15
MainItem3 SubItem1 - 10
MainItem3 SubItem2 - 9
what would be the best datastructure to store such data.?
Thanks in advance
Regards
ArunDhaJ- Hide quoted text -
- Show quoted text -