Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - use array or vector

Reply
 
Old 07-16-2008   #1 (permalink)
Daniel


 
 

use array or vector

Fernando Gómez wrote:
Quote:

> Daniel wrote:
Quote:

>> Why use that instead of ArrayList?
>>
>> Daniel
>>
>> "Ben Voigt [C++ MVP]" <rbv@xxxxxx> wrote in message
>> news:uY9UG345IHA.1176@xxxxxx
Quote:

>>> 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.

My System SpecsSystem Spec
Old 07-16-2008   #2 (permalink)
David Wilkinson


 
 

Re: use array or vector

Daniel wrote:
Quote:

> I need to use arrays that I can dimension during runtime. Is there a way to
> do that in VC++ .NET using arrays, or would I need to use vectors instead?
Daniel:

If this is a question about standard C++, you should have asked it in
microsoft.public.vc.language.

And the answer would have been: use std::vector.

--
David Wilkinson
Visual C++ MVP
My System SpecsSystem Spec
Old 07-16-2008   #3 (permalink)
Fernando Gómez


 
 

Re: use array or vector

David Wilkinson wrote:
Quote:

> Daniel wrote:
Quote:

>> I need to use arrays that I can dimension during runtime. Is there a
>> way to do that in VC++ .NET using arrays, or would I need to use
>> vectors instead?
>
> Daniel:
>
> If this is a question about standard C++, you should have asked it in
> microsoft.public.vc.language.
>
> And the answer would have been: use std::vector.
>
Or perhaps CArray (well, the OP didn't specify the library he was
using). Or something from System::Collections.

Regards.

My System SpecsSystem Spec
Old 07-16-2008   #4 (permalink)
Daniel


 
 

Re: use array or vector

What does OP stand for?

Daniel

"Fernando Gómez" <fernando.a.gomez.f@xxxxxx> wrote in message
news:OnRJRE25IHA.1468@xxxxxx
Quote:

> David Wilkinson wrote:
Quote:

>> Daniel wrote:
Quote:

>>> I need to use arrays that I can dimension during runtime. Is there a
>>> way to do that in VC++ .NET using arrays, or would I need to use vectors
>>> instead?
>>
>> Daniel:
>>
>> If this is a question about standard C++, you should have asked it in
>> microsoft.public.vc.language.
>>
>> And the answer would have been: use std::vector.
>>
>
> Or perhaps CArray (well, the OP didn't specify the library he was using).
> Or something from System::Collections.
>
> Regards.
>

My System SpecsSystem Spec
Old 07-16-2008   #5 (permalink)
Daniel


 
 

Re: use array or vector

I wanted to use an object from the newer .NET namespace.

Daniel

"David Wilkinson" <no-reply@xxxxxx> wrote in message
news:us7eBt15IHA.3480@xxxxxx
Quote:

> Daniel wrote:
Quote:

>> I need to use arrays that I can dimension during runtime. Is there a way
>> to do that in VC++ .NET using arrays, or would I need to use vectors
>> instead?
>
> Daniel:
>
> If this is a question about standard C++, you should have asked it in
> microsoft.public.vc.language.
>
> And the answer would have been: use std::vector.
>
> --
> David Wilkinson
> Visual C++ MVP

My System SpecsSystem Spec
Old 07-16-2008   #6 (permalink)
Daniel


 
 

Re: use array or vector

If I use std::vector, would my code still be portable to other .NET runtimes
on top of other platforms?

Daniel

"David Wilkinson" <no-reply@xxxxxx> wrote in message
news:us7eBt15IHA.3480@xxxxxx
Quote:

> Daniel wrote:
Quote:

>> I need to use arrays that I can dimension during runtime. Is there a way
>> to do that in VC++ .NET using arrays, or would I need to use vectors
>> instead?
>
> Daniel:
>
> If this is a question about standard C++, you should have asked it in
> microsoft.public.vc.language.
>
> And the answer would have been: use std::vector.
>
> --
> David Wilkinson
> Visual C++ MVP

My System SpecsSystem Spec
Old 07-16-2008   #7 (permalink)
Fernando Gómez


 
 

Re: use array or vector

Daniel wrote:
Quote:

> What does OP stand for?
>
> Daniel
Original Poster.
My System SpecsSystem Spec
Old 07-16-2008   #8 (permalink)
Fernando Gómez


 
 

Re: use array or vector

Daniel wrote:
Quote:

> I wanted to use an object from the newer .NET namespace.
>
> Daniel
>
Then you could use System::Collection::ArrayList.

Regards.
My System SpecsSystem Spec
Old 07-16-2008   #9 (permalink)
Ben Voigt [C++ MVP]


 
 

Re: use array or vector

Fernando Gómez wrote:
Quote:

> Daniel wrote:
Quote:

>> 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.
Quote:

>
> Regards.

My System SpecsSystem Spec
Old 07-16-2008   #10 (permalink)
Ben Voigt [C++ MVP]


 
 

Re: use array or vector

Daniel wrote:
Quote:

> If I use std::vector, would my code still be portable to other .NET
> runtimes on top of other platforms?
C++ code for .NET is only portable if
(1) You are using VC2005 or newer
(2) You pass /clrure, which disallows a lot of native stuff. Whether
std::vector still works I can't say, it may even depend on the type you are
using it with.
Quote:

>
> Daniel
>
> "David Wilkinson" <no-reply@xxxxxx> wrote in message
> news:us7eBt15IHA.3480@xxxxxx
Quote:

>> Daniel wrote:
Quote:

>>> I need to use arrays that I can dimension during runtime. Is there
>>> a way to do that in VC++ .NET using arrays, or would I need to use
>>> vectors instead?
>>
>> Daniel:
>>
>> If this is a question about standard C++, you should have asked it in
>> microsoft.public.vc.language.
>>
>> And the answer would have been: use std::vector.
>>
>> --
>> David Wilkinson
>> Visual C++ MVP

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Fast copy method of sub array (=array range) possible? VB Script
Stupid Array Tricks: Initializing an Array to a Certain Size PowerShell
True Vector Vista performance & maintenance
how to assign values to array and how to create array via variable PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46