I have an XML file that I deserialize into a class object. This class contains a number of other classes, some of which are arrays.
I would like to increase the array size of some of the objects.
How can I do this?
In the following example, the MyData object has an array size of 5 but the MyArrayClass say only has an array size of 1.
for (int i = 0; i < 5; i++)
{
MyMainClass.MyAnotherClass.MyArrayClass[i] = MyData[i];
}
This code thus fails because of the original array size of MyArrayClass. How do I increase it’s size?
thank you.
C# has manager memory – just delcare it a new array with size whatever you want. The garbage collector will clean up the old one for you if you don’t need the data. If you do, then create a new one of the size you want, and copy all of the old data over in which ever method you prefer, then just assign over the old one with the new one and let the garbage collector clean up the old one.