473,811 Members | 2,714 Online
Bytes | Software Development & Data Engineering Community
+ 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_Di sk" 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 1131
I'm having probably more fun than you with this new version :) Try:

array<Song^>^ diskSongs = nullptr;

diskSongs = gcnew array<Song^>(nu mberofSongs);

"Mark Prenter" <an**@anon.co m> wrote in message
news:%2******** ********@TK2MSF TNGP11.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_Di sk" 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************* *********@hotma il.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******** ******@TK2MSFTN GP10.phx.gbl...
I'm having probably more fun than you with this new version :) Try:

array<Song^>^ diskSongs = nullptr;

diskSongs = gcnew array<Song^>(nu mberofSongs);

"Mark Prenter" <an**@anon.co m> wrote in message
news:%2******** ********@TK2MSF TNGP11.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_Di sk" 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
2209
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 begs the question, what unit of measurement should we use for specifying font sizes, points or ems? Thanks. -Fleemo
11
4477
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 accomplish. // - - - - - - - - begin code - - - - - - - typedef int sm_t; typedef int bg_t; sm_t sm; bg_t bg;
15
5333
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 private string myArray;
19
3159
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 than in .Net environment, under VS 2005 Beta 2. Does anyone have any idea whether this will be addressed in the final release? Thanks, Tomasz
0
9727
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7669
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4339
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 we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.