Thanks for your explanation.
> Gilbert wrote:
>> H,
>>
>> i'm starting with asp.net/vb.net and have some questions about arrays and
>> collections:
>>
>> 1) what's the difference between:
>> dim x() as string
>> and
>> dim x as array
>
> The difference is that the first one is a reference to a string array,
> while the second one is a reference to any kind of array.
>
>> 2) can variable 'x' in the second case contain anything (string, integer
>> ... together)?
>
> Yes, and no. The reference can be used for any kind of array. If you
> assign it an array of strings, you can only put strings in that array. If
> you on the other hand assigns it an array of Object, you can put anything
> in the array.
>
>> 3) what is the correct syntax?
>> dim x as arraylist
>> or
>> dim x as arraylist()
>
> That depends on what you want to do. The first one declares a reference to
> an ArrayList, the second one declares a reference to an array of ArrayList
> objects.
>
>> 4) what to choose between:
>> dim x as array (or if no difference dim x() )
>> and
>> dim x as arraylist
>
> Again, that depends on what you want to do. The first one declares a
> reference to an array (of any type). The second one declares a reference
> to an ArrayList.
>
> An ArrayList is good if you want a list that grows dynamically. An array
> can not be resized.
>
> If you are using frameword 2.0, you can use a generi list instead of an
> ArrayList (unless you want to mix data types in the list). Generics has
> made ArrayList almost obsolete.
>
>> 5) what to choose between:
>> dim x as arraylist
>> and
>> dim x as list(of string)
>
> Guess what? It depends on what you want to do. ;)
>
> An ArrayList is equivalent to a List(Of Object). If you want a list where
> you can mix data types, that is what you can use. If you only want to put
> strings in the list, you should definitely choose the second one.
>
>
> --
> Göran Andersson
> _____
>
http://www.guffa.com