ArrayList vs Generics(List) question

etwombly

Member
Joined
Jun 8, 2007
Messages
9
Programming Experience
1-3
I'm having trouble wrapping my head around the both of these.

I'm trying to read in a reference table into a somewhat dynamic structure(not an array). The table has mainly 3 types, string/int/double. I tried originally using an ArrayList to read the table, which at the moment has around 60 rows, 12 columns, but it slowed my processing time dramatically. I've read that this is due to the boxing/unboxing, and that makes sense. I should note that I built an ArrayList of ArrayLists, maybe there is a better way to do it?

My question is, what's my best option for a data structure here? Lists seem to need one strong type, which won't work for me. I'm trying to convert from a two-dimensional array to something where I don't need to define bounds, and I'm a little lost. It also needs to be as fast as possible. If someone could point me in the right direction, that would be much appreciated.

Erik
 
I'm guessing that your "table" has rows that represent instances and columns that represent properties of the type. In that case you should define a class or structure that represents the type, where the class or structure has a property for each column. You then create a List of that type. For instance, let's say that you had a "table" that contained the first name, last name and date of birth of a number or people. You would define a Person class that had FirstName, LastName and DateOfBirth properties of type String, String and Date. You'd then create a List(Of Person) and add Person instances to it.
 
Back
Top