Re: use array or vector by Ben
Ben
Thu Jul 17 08:54:02 CDT 2008
Fernando Gómez wrote:
> Daniel wrote:
>> Why use that instead of ArrayList?
>>
>> Daniel
>>
>> "Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
>> news:uY9UG345IHA.1176@TK2MSFTNGP02.phx.gbl...
>>> Fernando Gómez wrote:
>>>> Daniel wrote:
>>>>> I wanted to use an object from the newer .NET namespace.
>>>>>
>>>>> Daniel
>>>>>
>>>> Then you could use System::Collection::ArrayList.
>>> Don't use ArrayList in new code.
>>>
>>> Use ::System::Collections::Generic::List<T> instead, with an
>>> appropriate value for T.
>>>
>>>> Regards.
>>>
>>
>>
> I'd guess that it is because List<T> is type safe, so you won't have
> to cast from object to you your particular type, etc.
And additionally far more efficient when used with value types, because it
doesn't require boxing and unboxing operations, inlines better, etc.