Jesper <je****@hotmail.com> wrote:
How, I would like to make a collection of integers. As an
integer is not a class I can't figure out how to store it
in a collection. The list will be generated dynamically.
Any suggestions.
int i = new int()
i = 5;
arrayList.Add(i) ... Seems to compile, but is this a
reccomended way to do it?
The above will work, but will take much more memory, because each value
is boxed. Unless you write your own version of ArrayList which stores
the values as an int[] however, you're not going to do much better. I
seem to remember that someone may have a tool somewhere to generate
collections like that automatically, but I don't have a URL for you.
I can't remember offhand whether the generics in the next version of
..NET will fix this problem or not, but it'd be nice if they did :)
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too