NameValueCollection

Convert the integer to a string using its ToString() method or the Convert class and its ToString method. You might want to look at a HashTable rather than nameValueCollection for anything else than strings.
 
Im not really sure if im following the code you gave me as I have no idea what its suppoded to do, but from what I see HashTable will work. HashTable is a Key/Object collection too.
[edit]You just edited your post, Ill reread it :)[/edit]
[edit]Ah I see now. So basically you are setting a number as key and the count as the value. HashTable is perfect for that kind of job.[/edit]
 
I think hashtable is not useful for my needs because it doesnt got a method to count how many times a specific key/value occurs in it or does it ?
 
Last edited by a moderator:
Same key cannot be added to a HashTable more than once.

Btw. dont make converting this to a hashtable a big priority in your program. NameValueCollection accepts strings. Integers are easily converted from/to strings so that will work too. But NameValueCollection wont work for other objects which you cant really convert to string and have a good result from it. I suggested this from a habit of using collections that fit the right object. I probably misunderstood your design too, so I might be totally off here.
 
ok there is a bug in my (actually not mine it is quoted from heiko) code so just forget it(I have also removed the code).... only thing im just trying to find out is how to calculate how many times a specific integer appears in some thing. This thing could be array,list,collection or something.

I dont want to do 2 x for loops if I use an array to find out which int occur most. Does anyone know if there is a collection/list/something which contains a method for calculating occurance ?
 
Last edited by a moderator:
Nevermind. Thx everyone who tried. I dont need it anymore it is too heavy for CPU I found a way to go around it.
 
Back
Top