is there some way to populate a list of custom type, similar to the way one can populate a list or an array with 1 statement, eg:
<code>
dim array() as string = array as string("erel", "george", "foo", "bar")
</code>
this is implied in list.addall(), but i'm not getting it to work with a custom type. the reason i'm using a custom type is because i want to sort the list later using a sort field. i started out with a map, but erel said to change to a list with a custom type and to chose a sort field. but i'm not getting the initial setup right.
so after an initial setup
<code>
Type customtype( name as string, id as int )
dim customtypelist as list
customtypelist.initialize
</code>
i'd like to be able to do something like this:
<code>
dim ct as customtype("erel", 1)
customtypelist.add( ct )
</code>
or like this:
<code>
dim ct as customtype = ("erel", 1)
customtypelist.add(ct)
</code>
or like this (best choice!)
<code>
customtypelist.addall( ("erel",1), ("george",2), ... )
</code>
what irks me is having to do it this way:
<code>
dim ct as customtype
ct.initialize
ct.name = "erel"
ct.id = 1
customtypelist.add(ct)
</code>
then cutting and pasting and editing the name and id for the remainder of the list one by one.
do i have to write a class to do any of the above? if any of my 3 preferences above is, in fact, doable,
i'm missing something in the execution.
thanks in advance
<code>
dim array() as string = array as string("erel", "george", "foo", "bar")
</code>
this is implied in list.addall(), but i'm not getting it to work with a custom type. the reason i'm using a custom type is because i want to sort the list later using a sort field. i started out with a map, but erel said to change to a list with a custom type and to chose a sort field. but i'm not getting the initial setup right.
so after an initial setup
<code>
Type customtype( name as string, id as int )
dim customtypelist as list
customtypelist.initialize
</code>
i'd like to be able to do something like this:
<code>
dim ct as customtype("erel", 1)
customtypelist.add( ct )
</code>
or like this:
<code>
dim ct as customtype = ("erel", 1)
customtypelist.add(ct)
</code>
or like this (best choice!)
<code>
customtypelist.addall( ("erel",1), ("george",2), ... )
</code>
what irks me is having to do it this way:
<code>
dim ct as customtype
ct.initialize
ct.name = "erel"
ct.id = 1
customtypelist.add(ct)
</code>
then cutting and pasting and editing the name and id for the remainder of the list one by one.
do i have to write a class to do any of the above? if any of my 3 preferences above is, in fact, doable,
i'm missing something in the execution.
thanks in advance