Array/list question

K

Kimmo Laine

Hello

i need two list that can be dynamically increased - one to store integers
and the other to store custom objects. I currently use ArrayList and it
works fine... Is there other choices? Is there a "IntList" or something -
when storing integers, ArrayList feels a little "heavy" to do this simple
task?


thx

Kimmo Laine
 
J

Jon Skeet [C# MVP]

Kimmo Laine said:
i need two list that can be dynamically increased - one to store integers
and the other to store custom objects. I currently use ArrayList and it
works fine... Is there other choices? Is there a "IntList" or something -
when storing integers, ArrayList feels a little "heavy" to do this simple
task?

ArrayList will work, but will end up boxing each int, causing more
memory usage and a bit of extra CPU work. How large is the int list
going to be? Unless it's got thousands and thousands of elements, I'd
just stick with ArrayList, to be honest. (In C# 2.0 of course you could
use List<int>.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top