Dynamics Array adding an object

  • Thread starter Thread starter Larry
  • Start date Start date
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??
 
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
 
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
 
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
 
Back
Top