Resizing an array is pretty painless in .NET 2.0 (the command was not available
in 1.1):
Array.Resize(ref myArr, myArr.Length + 1);
If an array has been initialized and is then resized smaller than it's original size,
and then resized back up again, the values will have been lost. This makes sense when you
think about it, but I thought it worth mentioning.
int[] myArr = new int[5] {0,1,2,3,4};
// myArr[3] is 3
// myArr[4] is 4
Array.Resize(ref myArr, 4);
Array.Resize(ref myArr, 5);
// myArr[3] is 3
// myArr[4] will now be 0
from a solution provided by Çetin Basöz in Message #1143663
|