Setting Array Size in .NET v2 (2005)

  • Thread starter Thread starter Mark Prenter
  • Start date Start date
M

Mark Prenter

Hi, I'm having a heck of a time figuring out arrays in the new version of
..NET. I'm used to .NET version 1. I'm trying to set the size of an array,
when an object is created.....let me explain it like this :

Let's say I have one object called "Compact_Disk" and a second object called
"Song". A compact disk can contain any number of songs.

In .NET v1, I could define my song array in my .h file as :

Song* diskSongs __gc[];

Then, when I initialize a Compct_Disk object, I could tell it how many songs
there are in the constructor, and have something like this in the code:

diskSongs = new Song* __gc[numberOfSongs]

How would I do something like this in VC++ 2005?

Please help while I still have hair left.

/\/\ark
 
I'm having probably more fun than you with this new version :) Try:

array<Song^>^ diskSongs = nullptr;

diskSongs = gcnew array<Song^>(numberofSongs);
 
diskSongs = new Song* __gc[numberOfSongs]
How would I do something like this in VC++ 2005?

array<int> ^myArray = gcnew array<int>(10);

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
THANKS A MILLION!!!

That's exactly what I needed.... nullptr

/\/\ark

Eddie Pazz said:
I'm having probably more fun than you with this new version :) Try:

array<Song^>^ diskSongs = nullptr;

diskSongs = gcnew array<Song^>(numberofSongs);

Mark Prenter said:
Hi, I'm having a heck of a time figuring out arrays in the new version of
.NET. I'm used to .NET version 1. I'm trying to set the size of an
array, when an object is created.....let me explain it like this :

Let's say I have one object called "Compact_Disk" and a second object
called "Song". A compact disk can contain any number of songs.

In .NET v1, I could define my song array in my .h file as :

Song* diskSongs __gc[];

Then, when I initialize a Compct_Disk object, I could tell it how many
songs there are in the constructor, and have something like this in the
code:

diskSongs = new Song* __gc[numberOfSongs]

How would I do something like this in VC++ 2005?

Please help while I still have hair left.

/\/\ark
 
Back
Top