[Tutor] C# defaultdict question
GTXY20
gtxy20 at gmail.com
Mon Apr 7 22:44:58 CEST 2008
Hello all,
Sadly I need to convert a great python application into C# .Net. I have been
pretty successful so far but I was wondering if anyone knew of something
similar to a python defaultdict(int) in C#. In python I am doing:
g = {} (where the value in the key value pair is a tuple of values)
f = defaultdict(int)
In order to get totals of particular values within each tuple within the
complete dictionary g I do:
for values in g.values():
for item in values:
f[item]+=1
I can accomplish this in C# by converting the values (which are stored as a
List) from a C# dictionary to an Array then looping through the Array but
was wondering if anyone had a different take or thoughts how to do this in
C# as easily as it is done in Python.
Thanks.
G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080407/37553148/attachment.htm
More information about the Tutor
mailing list