Resizing
Reducing Array Size
This can only be used when you have a one dimensional array.
char[ ] myarray = new char[4];
myarray[0] = 'a';
myarray[1] = 'b';
myarray[2] = 'c';
myarray[3] = 'd';
System.Array.Resize(ref myarray, 2);
string[] myArray;
System.Array.Resize(ref myArray, myArray.Length + 2);
Increasing Array Size
This can only be used when you have a one dimensional array.
char[ ] myarray = new char[2];
myarray[0] = 'a';
myarray[1] = 'b';
System.Array.Resize<char>(ref myarray, 4);
myarray[2] = 'c';
myarray[3] = 'd';
Resizing and Preserving
int[2] myarray;
int[ ] temp = new int[4];
myarray[0] = 'a';
myarray[1] = 'b';
System.Array.Copy(myarray, temp, myarray.Length);
myarray = temp
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext