Dynamics Array adding an object

L

Larry

thanks in advance..

if I have an array of objects, without using the array list.,
how do i add an additional element to the array dynamically while
preserving the current contents of the array?
anyone have any code samples??
 
S

Shaun C McDonnell

Larry,

Try this:

MyObject[] these = new MyObject[7];

for(int x=0; x<these.Length; x++)
{
these[x] = new MyObject();
these[x].MyProperty = "Whatever";
}

Shaun McDonnell
 
B

Brian Gideon

thanks in advance..

if I have an array of objects, without using the array list.,
how do i add an additional element to the array dynamically while
preserving the current contents of the array?
anyone have any code samples??

*** Sent via Developersdexhttp://www.developersdex.com***

Hi,

You'll have to create a new array and copy the original items into it
before copying the new item. Why can't you use the ArrayList or List
collections?

Brian
 
B

Ben Voigt

Brian Gideon said:
Hi,

You'll have to create a new array and copy the original items into it
before copying the new item. Why can't you use the ArrayList or List
collections?


Brian
 

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

Similar Threads


Top