Setting Array Size in .NET v2 (2005)

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
 
E

Eddie Pazz

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

array<Song^>^ diskSongs = nullptr;

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

Bruno van Dooren

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"
 
M

Mark Prenter

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top