// Initialize an array with 5 elements.char array = new char;
array = 'p';
array = 'y';
array = 't';
array = 'h';
array = 'o';
// We need an array with 6 elements.// ... Use Array.Resize to make a new array.Array.Resize<char>(ref array, 6);
// Assign the last element.
array = 'n';
// Display the array.
Notes, internals. A call to Array.Resize runs through an algorithm that determines that the array needs to be larger or smaller. It copies the array, and then changes the reference.
So Array.Resize does not resize the array. It replaces the array with a new one of a different size.
Copying an array completely when resizing it is wasteful in many situations. For these cases, use List—call Add() to add to empty space on the end.