I want the struct array to grow and shrink dynamically in c#.?
Ahmad
2009-08-25 05:50:52 UTC
I am trying to find help from the internet but i the help which is available on the internet is very professional and i can't understand properly.
Kindly Please help me and guide me because i have to implement this in of the program.
Four answers:
2009-08-25 07:34:28 UTC
Try using a list - you can create new structures and then add them to the list. Works much better than an array.
See http://www.c-sharpcorner.com/UploadFile/camurphy/csharpLists03302006170209PM/csharpLists.aspx for details.
2009-08-25 06:16:40 UTC
I don't think you can within a struct, however you could just have the struct contain a pointer to a block of data that is handled as an array.
I'm not particularly 'up' on C++ but I'm sure that would cause all sorts of memory management issues that you'd need to cover first though.
▐▀▀♦▀▀▌ ♦Oprah♦ ▐▄▄♦▄▄▌
2009-08-25 06:08:08 UTC
Arrays cannot be resized dynamically. You will need to allocate a new array, and copy the contents of the old array to the new one.
This function helps copying the elements:
System.Array.Copy(oldArray, newArray, length);
tbshmkr
2009-08-25 08:34:21 UTC
array.resize == Read source!!
=
http://dotnetperls.com/array-resize
// Example = = http://dotnetperls.com/array-resize