473,480 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Setting Array Size in .NET v2 (2005)

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

Mar 7 '06 #1
3 1112
I'm having probably more fun than you with this new version :) Try:

array<Song^>^ diskSongs = nullptr;

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

"Mark Prenter" <an**@anon.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Mar 7 '06 #2
> 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.
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 7 '06 #3
THANKS A MILLION!!!

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

/\/\ark

"Eddie Pazz" <dr****@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
I'm having probably more fun than you with this new version :) Try:

array<Song^>^ diskSongs = nullptr;

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

"Mark Prenter" <an**@anon.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Mar 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
2139
by: fleemo17 | last post by:
My organization is developing a set of "standards" for websites built inhouse. The first question that comes to mind is what would be a good standard default size for <p> text? 12 point? Which...
11
4429
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
15
5299
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
19
3123
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0...
0
7048
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.