I need a Datastructure, that can hold various datatypes.
for example:
myContainer has a Array of {(1,1 "hello"), (1,2 "bye"), ..}
Is that Datastructure right or should I use other kinds?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35258
7
posted
0
A List can only hold a single type, not multiple types. How about creating a class that has fields for those 3 types, and then keeping that in the List?
You could ofcourse use List<Object[]> but that would not be really type-safe. If the things you want to store are always triplets of Long, Float and String, then when you use a List<Object[]> the compiler will not be able to check that for you, and you might inadvertently put an Object[] into the list that contains something else than a Long, Float and String.