"watcher" <ti**********@tom.com> wrote in message
news:O8**************@TK2MSFTNGP14.phx.gbl...
when we redefine an array ,how can we preserve the old data?
string[] a = new string[1];
a[1] = "old data";
when we redefine the array a as following:
a = new string[2];
the data of a[1] was lost
what can i do to prevent it?
You would be best doing something like...
string[] b = new string[2];
Array.Copy(a,b,a.Length);
a = b;
It seems to me there is a resize method hiding somewhre in the framework as
well...but I can't recall what it is anylonger.